Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL Query - Large Number of Joins -
    primarykey
    data
    text
    <p>I have a SQL query that I'm using to pull in data from different tables for part details and fitment data. Unfortunately, the way the tables are laid out requires a lot of JOINs it seems. I currently have the following query and running it via phpmyadmin just displays a Loading screen, so I imagine it's timing out and wouldn't work in production.</p> <p>I've added indexes on the tables and columns joined. I've optimized the database via phpmyadmin, but I'm still stumped as to how this should or could be done. Do I have to split up the queries and combine them with UNION? If so, I'm not even sure how that'd work with this or IF it'd work.</p> <p>Please help. :-)</p> <pre><code>EXPLAIN SELECT Import_Values.base_vehicle_id, Import_Values.qty, Import_Values.part_type_id, Import_Values.part_id, Import_Values.position_id, Import_Values.note, Parts.partterminologyname, BaseVehicle.YearID, Make.MakeName, Model.modelname, SubModel.SubModelName, EngineDesignation.EngineDesignationName, EngineVIN.EngineVINName, EngineBase.Liter, EngineBase.CC, EngineBase.CID, EngineBase.Cylinders, EngineBase.BlockType, EngineBase.EngBoreIn, EngineBase.EngBoreMetric, EngineBase.EngStrokeIn, EngineBase.EngStrokeMetric, FuelDeliveryType.FuelDeliveryTypeName, FuelDeliverySubType.FuelDeliverySubTypeName, FuelSystemControlType.FuelSystemControlTypeName, FuelSystemDesign.FuelSystemDesignName, Aspiration.AspirationName, CylinderHeadType.CylinderHeadTypeName, FuelType.FuelTypeName, IgnitionSystemType.IgnitionSystemTypeName, Mfr.MfrName, EngineVersion.EngineVersion, Valves.ValvesPerEngine, BedLength.BedLength, BedLength.BedLengthMetric, BedType.BedTypeName FROM Import_Values INNER JOIN BaseVehicle ON Import_Values.base_vehicle_id=BaseVehicle.BaseVehicleID INNER JOIN Parts ON Import_Values.part_type_id=Parts.PartTerminologyID INNER JOIN Make ON BaseVehicle.MakeID=Make.MakeID INNER JOIN Model ON BaseVehicle.ModelID=Model.ModelID INNER JOIN Vehicle ON Import_Values.base_vehicle_id=Vehicle.BaseVehicleID INNER JOIN SubModel ON Vehicle.SubModelID=SubModel.SubModelID INNER JOIN VehicleToEngineConfig ON Vehicle.VehicleID=VehicleToEngineConfig.VehicleID INNER JOIN EngineConfig ON VehicleToEngineConfig.EngineConfigID=EngineConfig.EngineConfigID INNER JOIN EngineDesignation ON EngineConfig.EngineDesignationID=EngineDesignation.EngineDesignationID INNER JOIN EngineVIN ON EngineConfig.EngineVINID=EngineVIN.EngineVINID INNER JOIN EngineBase ON EngineConfig.EngineBaseID=EngineBase.EngineBaseID INNER JOIN FuelDeliveryConfig ON EngineConfig.FuelDeliveryConfigID=FuelDeliveryConfig.FuelDeliveryConfigID INNER JOIN FuelDeliveryType ON FuelDeliveryConfig.FuelDeliveryTypeID=FuelDeliveryType.FuelDeliveryTypeID INNER JOIN FuelDeliverySubType ON FuelDeliveryConfig.FuelDeliverySubTypeID=FuelDeliverySubType.FuelDeliverySubTypeID INNER JOIN FuelSystemControlType ON FuelDeliveryConfig.FuelSystemControlTypeID=FuelSystemControlType.FuelSystemControlTypeID INNER JOIN FuelSystemDesign ON FuelDeliveryConfig.FuelSystemDesignID=FuelSystemDesign.FuelSystemDesignID INNER JOIN Aspiration ON EngineConfig.AspirationID=Aspiration.AspirationID INNER JOIN CylinderHeadType ON EngineConfig.CylinderHeadTypeID=CylinderHeadType.CylinderHeadTypeID INNER JOIN FuelType ON EngineConfig.FuelTypeID=FuelType.FuelTypeID INNER JOIN IgnitionSystemType ON EngineConfig.IgnitionSystemTypeID=IgnitionSystemType.IgnitionSystemTypeID INNER JOIN Mfr ON EngineConfig.EngineMfrID=Mfr.MfrID INNER JOIN EngineVersion ON EngineConfig.EngineVersionID=EngineVersion.EngineVersionID INNER JOIN Valves ON EngineConfig.ValvesID=Valves.Valvesid INNER JOIN VehicleToBedConfig ON Vehicle.VehicleID=VehicleToBedConfig.VehicleID INNER JOIN BedConfig ON VehicleToBedConfig.BedConfigID=BedConfig.BedConfigID INNER JOIN BedLength ON BedConfig.BedLengthID=BedLength.BedLengthID INNER JOIN BedType ON BedConfig.BedTypeID=BedType.BedTypeID </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload