mysql - How to optimize SQL Query with INNER JOINs -
i have large database table access document. includes different tables each attribute fitment of auto part. 1 can imagine, fitment data contains lot of specifications , such, spread out.
now building query map values database becoming difficult. have following query seems contains many joins... , add more, seems take bit longer run. there better way going this?
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 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
any advice appreciated!
define indizes on columns in on clauses. use explain select
see indizes used.
Comments
Post a Comment