使用128GB的RAM进行查询

时间:2014-02-28 22:07:40

标签: mysql

我一直在努力处理一个我尚未成功运行的大型查询。每次我运行它,它都会意外地显示出“被杀”。最后看了之后,我发现在进程被杀死并且内存恢复正常之前的大约20-30分钟,内存使用量从10GB增加到128GB。

EXPLAIN SELECT结果can be seen here

查询本身可以在这里看到:

SELECT
Import_AcesApplication_New.sku,
Import_AcesApplication_New.notes,
Parts.partterminologyname,
BaseVehicle.YearID,
Make.MakeName,
Model.modelname,
Submodel.SubmodelName,
CONCAT(EngineBase.Cylinders, ' Cyl ', EngineBase.Liter, 'L') as engine,
Positions.position,
BedLength.BedLength,
BedLength.BedLengthMetric,
BedType.BedTypeName,
BodyNumDoors.BodyNumDoors,
BodyType.BodyTypeName,
FrontBrakeType.BrakeTypeName,
RearBrakeType.BrakeTypeName,
BrakeSystem.BrakeSystemName,
BrakeABS.BrakeABSName,
DriveType.DriveTypeName,
EngineDesignation.EngineDesignationName,
EngineVIN.EngineVINName,
Valves.ValvesPerEngine,
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,
EngineMfr.MfrName,
EngineVersion.EngineVersion,
PowerOutput.HorsePower,
PowerOutput.KilowattPower,
SpringType.SpringTypeName,
SteeringType.SteeringTypeName,
SteeringSystem.SteeringSystemName,
TransmissionType.TransmissionTypeName,
TransmissionNumSpeeds.TransmissionNumSpeeds,
TransmissionMfrCode.TransmissionMfrCode,
TransElecControlled.ElecControlled,
TransmissionMfr.MfrName,
WheelBase.WheelBase,
WheelBase.WheelBaseMetric,
VehicleType.VehicleTypeName,
VehicleTypeGroup.VehicleTypeGroupName
FROM
Import_AcesApplication_New
STRAIGHT_JOIN BaseVehicle ON Import_AcesApplication_New.base_vehicle_id=BaseVehicle.BaseVehicleID
STRAIGHT_JOIN Parts ON Import_AcesApplication_New.part_type_id=Parts.PartTerminologyID
STRAIGHT_JOIN Make ON BaseVehicle.MakeID=Make.MakeID
STRAIGHT_JOIN Model ON BaseVehicle.ModelID=Model.ModelID
STRAIGHT_JOIN Vehicle ON Import_AcesApplication_New.base_vehicle_id=Vehicle.BaseVehicleID
STRAIGHT_JOIN Submodel ON Vehicle.SubmodelID=Submodel.SubmodelID
STRAIGHT_JOIN VehicleToBedConfig ON Vehicle.VehicleID=VehicleToBedConfig.VehicleID
STRAIGHT_JOIN VehicleToBodyStyleConfig ON Vehicle.VehicleID=VehicleToBodyStyleConfig.VehicleID
STRAIGHT_JOIN VehicleToBrakeConfig ON Vehicle.VehicleID=VehicleToBrakeConfig.VehicleID
STRAIGHT_JOIN VehicleToDriveType ON Vehicle.VehicleID=VehicleToDriveType.VehicleID
STRAIGHT_JOIN VehicleToEngineConfig ON Vehicle.VehicleID=VehicleToEngineConfig.VehicleID
STRAIGHT_JOIN VehicleToSpringTypeConfig ON Vehicle.VehicleID=VehicleToSpringTypeConfig.VehicleID
STRAIGHT_JOIN VehicleToSteeringConfig ON Vehicle.VehicleID=VehicleToSteeringConfig.VehicleID
STRAIGHT_JOIN VehicleToTransmission ON Vehicle.VehicleID=VehicleToTransmission.VehicleID
STRAIGHT_JOIN VehicleToWheelbase ON Vehicle.VehicleID=VehicleToWheelbase.VehicleID
STRAIGHT_JOIN EngineConfig ON VehicleToEngineConfig.EngineConfigID=EngineConfig.EngineConfigID
STRAIGHT_JOIN EngineBase ON EngineConfig.EngineBaseID=EngineBase.EngineBaseID
STRAIGHT_JOIN Positions ON Import_AcesApplication_New.position_id=Positions.PositionID
STRAIGHT_JOIN BedConfig ON VehicleToBedConfig.BedConfigID=BedConfig.BedConfigID
STRAIGHT_JOIN BedLength ON BedConfig.BedLengthID=BedLength.BedLengthID
STRAIGHT_JOIN BedType ON BedConfig.BedTypeID=BedType.BedTypeID
STRAIGHT_JOIN BodyStyleConfig ON VehicleToBodyStyleConfig.BodyStyleConfigID=BodyStyleConfig.BodyStyleConfigID
STRAIGHT_JOIN BodyNumDoors ON BodyStyleConfig.BodyNumDoorsID=BodyNumDoors.BodyNumDoorsID
STRAIGHT_JOIN BodyType ON BodyStyleConfig.BodyTypeID=BodyType.BodyTypeID
STRAIGHT_JOIN BrakeConfig ON VehicleToBrakeConfig.BrakeConfigID=BrakeConfig.BrakeConfigID
STRAIGHT_JOIN BrakeType FrontBrakeType ON BrakeConfig.FrontBrakeTypeID=FrontBrakeType.BrakeTypeID
STRAIGHT_JOIN BrakeType RearBrakeType ON BrakeConfig.RearBrakeTypeID=RearBrakeType.BrakeTypeID
STRAIGHT_JOIN BrakeSystem ON BrakeConfig.BrakeSystemID=BrakeSystem.BrakeSystemID
STRAIGHT_JOIN BrakeABS ON BrakeConfig.BrakeABSID=BrakeABS.BrakeABSID
STRAIGHT_JOIN DriveType ON VehicleToDriveType.DriveTypeID=DriveType.DriveTypeID
STRAIGHT_JOIN EngineDesignation ON EngineConfig.EngineDesignationID=EngineDesignation.EngineDesignationID
STRAIGHT_JOIN EngineVIN ON EngineConfig.EngineVINID=EngineVIN.EngineVINID
STRAIGHT_JOIN Valves ON EngineConfig.ValvesID=Valves.Valvesid
STRAIGHT_JOIN FuelDeliveryConfig ON EngineConfig.FuelDeliveryConfigID=FuelDeliveryConfig.FuelDeliveryConfigID
STRAIGHT_JOIN FuelDeliveryType ON FuelDeliveryConfig.FuelDeliveryTypeID=FuelDeliveryType.FuelDeliveryTypeID
STRAIGHT_JOIN FuelDeliverySubType ON FuelDeliveryConfig.FuelDeliverySubTypeID=FuelDeliverySubType.FuelDeliverySubTypeID
STRAIGHT_JOIN FuelSystemControlType ON FuelDeliveryConfig.FuelSystemControlTypeID=FuelSystemControlType.FuelSystemControlTypeID
STRAIGHT_JOIN FuelSystemDesign ON FuelDeliveryConfig.FuelSystemDesignID=FuelSystemDesign.FuelSystemDesignID
STRAIGHT_JOIN Aspiration ON EngineConfig.AspirationID=Aspiration.AspirationID
STRAIGHT_JOIN CylinderHeadType ON EngineConfig.CylinderHeadTypeID=CylinderHeadType.CylinderHeadTypeID
STRAIGHT_JOIN FuelType ON EngineConfig.FuelTypeID=FuelType.FuelTypeID
STRAIGHT_JOIN IgnitionSystemType ON EngineConfig.IgnitionSystemTypeID=IgnitionSystemType.IgnitionSystemTypeID
STRAIGHT_JOIN Mfr EngineMfr ON EngineConfig.EngineMfrID=EngineMfr.MfrID
STRAIGHT_JOIN EngineVersion ON EngineConfig.EngineVersionID=EngineVersion.EngineVersionID
STRAIGHT_JOIN PowerOutput ON EngineConfig.PowerOutputId=PowerOutput.PowerOutputId
STRAIGHT_JOIN SpringType ON VehicleToSpringTypeConfig.SpringTypeConfigID=SpringType.SpringTypeID
STRAIGHT_JOIN SteeringConfig ON VehicleToSteeringConfig.SteeringConfigID=SteeringConfig.SteeringConfigID
STRAIGHT_JOIN SteeringType ON SteeringConfig.SteeringConfigID=SteeringType.SteeringTypeID
STRAIGHT_JOIN SteeringSystem ON SteeringConfig.SteeringSystemID=SteeringSystem.SteeringSystemID
STRAIGHT_JOIN Transmission ON VehicleToTransmission.TransmissionID=Transmission.TransmissionID
STRAIGHT_JOIN TransmissionBase ON Transmission.TransmissionBaseID=TransmissionBase.TransmissionBaseID
STRAIGHT_JOIN TransmissionType ON TransmissionBase.TransmissionTypeID=TransmissionType.TransmissionTypeID
STRAIGHT_JOIN TransmissionNumSpeeds ON TransmissionBase.TransmissionNumSpeedsID=TransmissionNumSpeeds.TransmissionNumSpeedsID
STRAIGHT_JOIN TransmissionControlType ON TransmissionBase.TransmissionControlTypeID=TransmissionControlType.TransmissionControlTypeID
STRAIGHT_JOIN TransmissionMfrCode ON Transmission.TransmissionMfrCodeID=TransmissionMfrCode.TransmissionMfrCodeID
STRAIGHT_JOIN ElecControlled TransElecControlled ON Transmission.TransmissionElecControlledID=TransElecControlled.ElecControlledID
STRAIGHT_JOIN Mfr TransmissionMfr ON Transmission.TransmissionMfrID=TransmissionMfr.MfrID
STRAIGHT_JOIN WheelBase ON VehicleToWheelbase.WheelbaseID=WheelBase.WheelBaseID
STRAIGHT_JOIN VehicleType ON Model.VehicleTypeID=VehicleType.VehicleTypeID
STRAIGHT_JOIN VehicleTypeGroup ON VehicleType.VehicleTypeGroupId=VehicleTypeGroup.VehicleTypeGroupId

我可以做些什么来优化查询以便完成(没有咀嚼超过100GB的数据)?

谢谢!

2 个答案:

答案 0 :(得分:0)

我会看一下使用表来保存你需要的结果并按照许多步骤填充。

例如,使用简化的导入表和make和model的查找表:

create table imp( sku int, notes varchar(20), make_id int, model_id int ) ;
create table make ( id int, make_name varchar(20) ) ;
create table model ( id int, model_name varchar(20) ) ;

为我们的结果创建一个表:

create table res( sku int, 
                  notes varchar(20), 
                  make varchar(20), 
                  model varchar(20) 
                );

坚持一些样本数据:

insert into imp values
( 1, 'blue ford focus', 2, 3 ), 
( 2,'green audi a4', 1, 2 ), 
( 3,'black audi a3', 1, 1 );

insert into make values( 1, 'audi'), (2,'ford');

insert into model values( 1, 'a3'), (2,'a4'), (3,'focus');

现在获取我们感兴趣的所有导入数据

insert into res ( sku, notes ) select sku,notes from imp; 

修复make

update res 
join imp on res.sku = imp.sku
join make on imp.make_id = make.id
set res.make = make.make_name ;

和模型

update res 
join imp on res.sku = imp.sku
join model on imp.model_id = model.id
set res.model = model.model_name;

现在得到我们想要的结果......

select * from res;

http://sqlfiddle.com/#!2/36fdc2/1

使用这样的技术,您可以将查询分成几个查询,每个查询都会运行。

您可能希望在结果表中添加索引(上例中的sku)

答案 1 :(得分:0)

对于每辆车的所有不同型号和子模型以及设备,您似乎得到了笛卡尔结果。你可以做一个测试,并为一个单独的“Import_AcesApplication_New.base_vehicle_id”添加一个WHERE子句,看看有多少记录被返回...

然后,给我们计算“Import_AcesApplication_New”表中的总记录数。从所有表中获取计数可能会很好,因为这显然会阻塞您的服务器。

在同一时间,我正在尝试处理查询并将回发到更易于管理的部分......但是“STRAIGHT_JOIN”仅在查询顶部需要ONCE,其余部分都是正常连接。 / p>

select STRAIGHT_JOIN
     fields, fields, fields
   from
      yourTables
         JOIN Other Tables on ...

另外,在我回答并最初建议使用STRAIGHT_JOIN的原始问题中,我还建议覆盖所有表格的索引。你有没有创建这些索引?

好的,更多的是要咀嚼...我重写了你的查询,只是改组连接的顺序,以显示沿途的子组件的相关性..

SELECT STRAIGHT_JOIN
      IAN.sku,
      IAN.notes,
      Parts.partterminologyname,
      BaseVehicle.YearID,
      Make.MakeName,
      Model.modelname,
      Submodel.SubmodelName,
      CONCAT(EngineBase.Cylinders, ' Cyl ', EngineBase.Liter, 'L') as engine,
      Positions.position,
      BedLength.BedLength,
      BedLength.BedLengthMetric,
      BedType.BedTypeName,
      BodyNumDoors.BodyNumDoors,
      BodyType.BodyTypeName,
      FrontBrakeType.BrakeTypeName,
      RearBrakeType.BrakeTypeName,
      BrakeSystem.BrakeSystemName,
      BrakeABS.BrakeABSName,
      DriveType.DriveTypeName,
      EngineDesignation.EngineDesignationName,
      EngineVIN.EngineVINName,
      Valves.ValvesPerEngine,
      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,
      EngineMfr.MfrName,
      EngineVersion.EngineVersion,
      PowerOutput.HorsePower,
      PowerOutput.KilowattPower,
      SpringType.SpringTypeName,
      SteeringType.SteeringTypeName,
      SteeringSystem.SteeringSystemName,
      TransmissionType.TransmissionTypeName,
      TransmissionNumSpeeds.TransmissionNumSpeeds,
      TransmissionMfrCode.TransmissionMfrCode,
      TransElecControlled.ElecControlled,
      TransmissionMfr.MfrName,
      WheelBase.WheelBase,
      WheelBase.WheelBaseMetric,
      VehicleType.VehicleTypeName,
      VehicleTypeGroup.VehicleTypeGroupName
   FROM
      Import_AcesApplication_New IAN
         JOIN BaseVehicle 
            ON IAN.base_vehicle_id = BaseVehicle.BaseVehicleID
            JOIN Make 
               ON BaseVehicle.MakeID = Make.MakeID
            JOIN Model 
               ON BaseVehicle.ModelID = Model.ModelID
               JOIN VehicleType 
                  ON Model.VehicleTypeID = VehicleType.VehicleTypeID
                  JOIN VehicleTypeGroup 
                     ON VehicleType.VehicleTypeGroupId = VehicleTypeGroup.VehicleTypeGroupId

         JOIN Parts 
            ON IAN.part_type_id = Parts.PartTerminologyID


         JOIN Vehicle 
            ON IAN.base_vehicle_id = Vehicle.BaseVehicleID
            JOIN Submodel 
               ON Vehicle.SubmodelID = Submodel.SubmodelID

            JOIN VehicleToBedConfig 
               ON Vehicle.VehicleID = VehicleToBedConfig.VehicleID
               JOIN BedConfig 
                  ON VehicleToBedConfig.BedConfigID = BedConfig.BedConfigID
                  JOIN BedLength 
                     ON BedConfig.BedLengthID = BedLength.BedLengthID
                  JOIN BedType 
                     ON BedConfig.BedTypeID = BedType.BedTypeID

            JOIN VehicleToBodyStyleConfig 
               ON Vehicle.VehicleID = VehicleToBodyStyleConfig.VehicleID
               JOIN BodyStyleConfig 
                  ON VehicleToBodyStyleConfig.BodyStyleConfigID = BodyStyleConfig.BodyStyleConfigID
                  JOIN BodyNumDoors 
                     ON BodyStyleConfig.BodyNumDoorsID = BodyNumDoors.BodyNumDoorsID
                  JOIN BodyType 
                     ON BodyStyleConfig.BodyTypeID = BodyType.BodyTypeID

            JOIN VehicleToBrakeConfig 
               ON Vehicle.VehicleID = VehicleToBrakeConfig.VehicleID
               JOIN BrakeConfig 
                  ON VehicleToBrakeConfig.BrakeConfigID = BrakeConfig.BrakeConfigID
                  JOIN BrakeType FrontBrakeType 
                     ON BrakeConfig.FrontBrakeTypeID = FrontBrakeType.BrakeTypeID
                  JOIN BrakeType RearBrakeType 
                     ON BrakeConfig.RearBrakeTypeID = RearBrakeType.BrakeTypeID
                  JOIN BrakeSystem 
                     ON BrakeConfig.BrakeSystemID = BrakeSystem.BrakeSystemID
                  JOIN BrakeABS 
                     ON BrakeConfig.BrakeABSID = BrakeABS.BrakeABSID

            JOIN VehicleToDriveType 
               ON Vehicle.VehicleID = VehicleToDriveType.VehicleID
               JOIN DriveType 
                  ON VehicleToDriveType.DriveTypeID = DriveType.DriveTypeID

            JOIN VehicleToEngineConfig 
               ON Vehicle.VehicleID = VehicleToEngineConfig.VehicleID
               JOIN EngineConfig 
                  ON VehicleToEngineConfig.EngineConfigID = EngineConfig.EngineConfigID
                  JOIN EngineBase 
                     ON EngineConfig.EngineBaseID = EngineBase.EngineBaseID
                  JOIN EngineDesignation 
                     ON EngineConfig.EngineDesignationID = EngineDesignation.EngineDesignationID
                  JOIN EngineVIN 
                     ON EngineConfig.EngineVINID = EngineVIN.EngineVINID
                  JOIN Valves 
                     ON EngineConfig.ValvesID = Valves.Valvesid
                  JOIN FuelDeliveryConfig 
                     ON EngineConfig.FuelDeliveryConfigID = FuelDeliveryConfig.FuelDeliveryConfigID
                     JOIN FuelDeliveryType 
                        ON FuelDeliveryConfig.FuelDeliveryTypeID = FuelDeliveryType.FuelDeliveryTypeID
                     JOIN FuelDeliverySubType 
                        ON FuelDeliveryConfig.FuelDeliverySubTypeID = FuelDeliverySubType.FuelDeliverySubTypeID
                     JOIN FuelSystemControlType 
                        ON FuelDeliveryConfig.FuelSystemControlTypeID = FuelSystemControlType.FuelSystemControlTypeID
                     JOIN FuelSystemDesign 
                        ON FuelDeliveryConfig.FuelSystemDesignID = FuelSystemDesign.FuelSystemDesignID
                  JOIN Aspiration 
                     ON EngineConfig.AspirationID = Aspiration.AspirationID
                  JOIN CylinderHeadType 
                     ON EngineConfig.CylinderHeadTypeID = CylinderHeadType.CylinderHeadTypeID
                  JOIN FuelType 
                     ON EngineConfig.FuelTypeID = FuelType.FuelTypeID
                  JOIN IgnitionSystemType 
                     ON EngineConfig.IgnitionSystemTypeID = IgnitionSystemType.IgnitionSystemTypeID
                  JOIN Mfr EngineMfr 
                     ON EngineConfig.EngineMfrID = EngineMfr.MfrID
                  JOIN EngineVersion 
                     ON EngineConfig.EngineVersionID = EngineVersion.EngineVersionID
                  JOIN PowerOutput 
                     ON EngineConfig.PowerOutputId = PowerOutput.PowerOutputId


            JOIN VehicleToSpringTypeConfig 
               ON Vehicle.VehicleID = VehicleToSpringTypeConfig.VehicleID
               JOIN SpringType 
                  ON VehicleToSpringTypeConfig.SpringTypeConfigID = SpringType.SpringTypeID
            JOIN VehicleToSteeringConfig 
               ON Vehicle.VehicleID = VehicleToSteeringConfig.VehicleID
               JOIN SteeringConfig 
                  ON VehicleToSteeringConfig.SteeringConfigID = SteeringConfig.SteeringConfigID
                  JOIN SteeringType 
                     ON SteeringConfig.SteeringConfigID = SteeringType.SteeringTypeID
                  JOIN SteeringSystem 
                     ON SteeringConfig.SteeringSystemID = SteeringSystem.SteeringSystemID

            JOIN VehicleToTransmission 
               ON Vehicle.VehicleID = VehicleToTransmission.VehicleID
               JOIN Transmission 
                  ON VehicleToTransmission.TransmissionID = Transmission.TransmissionID
                  JOIN TransmissionBase 
                     ON Transmission.TransmissionBaseID = TransmissionBase.TransmissionBaseID
                     JOIN TransmissionType 
                        ON TransmissionBase.TransmissionTypeID = TransmissionType.TransmissionTypeID
                     JOIN TransmissionNumSpeeds 
                        ON TransmissionBase.TransmissionNumSpeedsID = TransmissionNumSpeeds.TransmissionNumSpeedsID
                     JOIN TransmissionControlType 
                        ON TransmissionBase.TransmissionControlTypeID = TransmissionControlType.TransmissionControlTypeID
                  JOIN ElecControlled TransElecControlled 
                     ON Transmission.TransmissionElecControlledID = TransElecControlled.ElecControlledID
                  JOIN Mfr TransmissionMfr 
                     ON Transmission.TransmissionMfrID = TransmissionMfr.MfrID
                  JOIN TransmissionMfrCode 
                     ON Transmission.TransmissionMfrCodeID = TransmissionMfrCode.TransmissionMfrCodeID

            JOIN VehicleToWheelbase 
               ON Vehicle.VehicleID = VehicleToWheelbase.VehicleID
               JOIN WheelBase 
                  ON VehicleToWheelbase.WheelbaseID = WheelBase.WheelBaseID

         JOIN Positions 
            ON IAN.position_id = Positions.PositionID

然后,在看了这个之后,我试着看看我可能会变成“预先查询”汇总表 - 其中大多数是基于vehicle_id。所以,我通过车身,刹车,发动机,变速器等子组件创建了几个连接,并提出了......

SELECT STRAIGHT_JOIN
      IAN.sku,
      IAN.notes,
      Parts.partterminologyname,

      PQBaseVehicle.YearID,
      PQBaseVehicle.MakeName,
      PQBaseVehicle.modelname,
      PQBaseVehicle.VehicleTypeName,
      PQBaseVehicle.VehicleTypeGroupName,

      PQVTrans.TransmissionTypeName,
      PQVTrans.TransmissionNumSpeeds,
      PQVTrans.ElecControlled,
      PQVTrans.MfrName,
      PQVTrans.TransmissionMfrCode,

      PQEngine.Engine,
      PQEngine.Liter,
      PQEngine.CC,
      PQEngine.CID,
      PQEngine.Cylinders,
      PQEngine.BlockType,
      PQEngine.EngBoreIn,
      PQEngine.EngBoreMetric,
      PQEngine.EngStrokeIn,
      PQEngine.EngStrokeMetric,
      PQEngine.EngineDesignationName,
      PQEngine.EngineVINName,
      PQEngine.ValvesPerEngine,
      PQEngine.FuelDeliveryTypeName,
      PQEngine.FuelDeliverySubTypeName,
      PQEngine.FuelSystemControlTypeName,
      PQEngine.FuelSystemDesignName,
      PQEngine.AspirationName,
      PQEngine.CylinderHeadTypeName,
      PQEngine.FuelTypeName,
      PQEngine.IgnitionSystemTypeName,
      PQEngine.MfrName,
      PQEngine.EngineVersion,
      PQEngine.HorsePower,
      PQEngine.KilowattPower,

      PQBrakes.FrontBrakeTypeName,
      PQBrakes.RearBrakeTypeName,
      PQBrakes.BrakeSystemName,
      PQBrakes.BrakeABSName,

      PQBody.BodyNumDoors,
      PQBody.BodyTypeName,

      PQBeds.BedLength,
      PQBeds.BedLengthMetric,
      PQBeds.BedTypeName,

      PQSteering.SteeringTypeName,
      PQSteering.SteeringSystemName,

      Submodel.SubmodelName,
      Positions.position,
      DriveType.DriveTypeName,
      SpringType.SpringTypeName,
      WheelBase.WheelBase,
      WheelBase.WheelBaseMetric
   FROM
      Import_AcesApplication_New IAN
         JOIN Parts 
            ON IAN.part_type_id = Parts.PartTerminologyID
         JOIN Positions 
            ON IAN.position_id = Positions.PositionID

         JOIN ( select STRAIGHT_JOIN
                      BaseVehicle.BaseVehicleID,
                      BaseVehicle.YearID,
                      Make.MakeName,
                      Model.modelname,
                      VehicleType.VehicleTypeName,
                      VehicleTypeGroup.VehicleTypeGroupName
                   from 
                      BaseVehicle 
                         JOIN Make 
                            ON BaseVehicle.MakeID = Make.MakeID
                            JOIN Model 
                               ON BaseVehicle.ModelID = Model.ModelID
                               JOIN VehicleType 
                                  ON Model.VehicleTypeID = VehicleType.VehicleTypeID
                                  JOIN VehicleTypeGroup 
                                     ON VehicleType.VehicleTypeGroupId = VehicleTypeGroup.VehicleTypeGroupId ) PQBaseVehicle
            ON IAN.base_vehicle_id = PQBaseVehicle.BaseVehicleID

         JOIN Vehicle 
            ON IAN.base_vehicle_id = Vehicle.BaseVehicleID
            JOIN Submodel 
               ON Vehicle.SubmodelID = Submodel.SubmodelID

            JOIN VehicleToWheelbase 
               ON Vehicle.VehicleID = VehicleToWheelbase.VehicleID
               JOIN WheelBase 
                  ON VehicleToWheelbase.WheelbaseID = WheelBase.WheelBaseID

            JOIN VehicleToDriveType 
               ON Vehicle.VehicleID = VehicleToDriveType.VehicleID
               JOIN DriveType 
                  ON VehicleToDriveType.DriveTypeID = DriveType.DriveTypeID

            JOIN VehicleToSpringTypeConfig 
               ON Vehicle.VehicleID = VehicleToSpringTypeConfig.VehicleID
               JOIN SpringType 
                  ON VehicleToSpringTypeConfig.SpringTypeConfigID = SpringType.SpringTypeID

            JOIN ( SELECT STRAIGHT_JOIN
                         VSC.VehicleID,
                         ST.SteeringTypeName,
                         SS.SteeringSystemName
                      FROM
                         VehicleToSteeringConfig VSC
                            JOIN SteeringConfig SC
                               ON VSC.SteeringConfigID = SC.SteeringConfigID
                               JOIN SteeringType ST
                                  ON SC.SteeringConfigID = ST.SteeringTypeID
                               JOIN SteeringSystem SS
                                  ON SC.SteeringSystemID = SS.SteeringSystemID ) PQSteering
               ON Vehicle.VehicleID = PQSteering.VehicleID


            JOIN ( SELECT STRAIGHT_JOIN
                         VBC.VehicleID,
                         BL.BedLength,
                         BL.BedLengthMetric,
                         BT.BedTypeName
                      FROM
                         VehicleToBedConfig VBC
                            ON Vehicle.VehicleID = VBC.VehicleID
                            JOIN BedConfig BC
                               ON VBC.BedConfigID = BC.BedConfigID
                               JOIN BedLength BL
                                  ON BC.BedLengthID = BL.BedLengthID
                               JOIN BedType BT
                                  ON BC.BedTypeID = BT.BedTypeID ) PQBeds
               ON Vehicle.VehicleID = PQBeds.VehicleID


            JOIN ( SELECT STRAIGHT_JOIN
                         VBSC.VehicleID,
                         BND.BodyNumDoors,
                         BT.BodyTypeName
                      FROM
                         VehicleToBodyStyleConfig VBSC
                            JOIN BodyStyleConfig BSC
                               ON VBSC.BodyStyleConfigID = BSC.BodyStyleConfigID
                               JOIN BodyNumDoors BND
                                  ON BSC.BodyNumDoorsID = BND.BodyNumDoorsID
                               JOIN BodyType BT
                                  ON BSC.BodyTypeID = BT.BodyTypeID ) PQBody
               ON Vehicle.VehicleID = PQBody.VehicleID


            JOIN ( SELECT STRAIGHT_JOIN
                         VBC.VehicleID,
                         FBT.BrakeTypeName FrontBrakeTypeName,
                         RBT.BrakeTypeName RearBrakeTypeName,
                         BS.BrakeSystemName,
                         BrakeABS.BrakeABSName
                      FROM
                         VehicleToBrakeConfig VBC
                            JOIN BrakeConfig BC
                               ON VBC.BrakeConfigID = BC.BrakeConfigID
                               JOIN BrakeType FBT 
                                  ON BC.FrontBrakeTypeID = FBT.BrakeTypeID
                               JOIN BrakeType RBT
                                  ON BC.RearBrakeTypeID = RBT.BrakeTypeID
                               JOIN BrakeSystem BS
                                  ON BC.BrakeSystemID = BS.BrakeSystemID
                               JOIN BrakeABS 
                                  ON BC.BrakeABSID = BrakeABS.BrakeABSID ) PQBrakes
               ON Vehicle.VehicleID = PQBrakes.VehicleID

            JOIN ( select STRAIGHT_JOIN
                         VEC.VehicleID,
                         CONCAT(EB.Cylinders, ' Cyl ', EB.Liter, 'L') as engine,
                         EB.Liter,
                         EB.CC,
                         EB.CID,
                         EB.Cylinders,
                         EB.BlockType,
                         EB.EngBoreIn,
                         EB.EngBoreMetric,
                         EB.EngStrokeIn,
                         EB.EngStrokeMetric,
                         ED.EngineDesignationName,
                         EVIN.EngineVINName,
                         V.ValvesPerEngine,
                         FDT.FuelDeliveryTypeName,
                         FDST.FuelDeliverySubTypeName,
                         FSCT.FuelSystemControlTypeName,
                         FSD.FuelSystemDesignName,
                         Asp.AspirationName,
                         CHT.CylinderHeadTypeName,
                         FT.FuelTypeName,
                         IST.IgnitionSystemTypeName,
                         EMFR.MfrName,
                         EVer.EngineVersion,
                         PO.HorsePower,
                         PO.KilowattPower
                      from
                         VehicleToEngineConfig VEC
                            JOIN EngineConfig EC
                               ON VEC.EngineConfigID = EC.EngineConfigID
                               JOIN EngineBase EB
                                  ON EC.EngineBaseID = EB.EngineBaseID
                               JOIN EngineDesignation ED
                                  ON EC.EngineDesignationID = ED.EngineDesignationID
                               JOIN EngineVIN EVIN
                                  ON EC.EngineVINID = EVIN.EngineVINID
                               JOIN Valves V
                                  ON EC.ValvesID = V.Valvesid
                               JOIN FuelDeliveryConfig FDC
                                  ON EC.FuelDeliveryConfigID = FDC.FuelDeliveryConfigID
                                  JOIN FuelDeliveryType FDT
                                     ON FDC.FuelDeliveryTypeID = FDT.FuelDeliveryTypeID
                                  JOIN FuelDeliverySubType FDST
                                     ON FDC.FuelDeliverySubTypeID = FDST.FuelDeliverySubTypeID
                                  JOIN FuelSystemControlType FSCT
                                     ON FDC.FuelSystemControlTypeID = FSCT.FuelSystemControlTypeID
                                  JOIN FuelSystemDesign FSD
                                     ON FDC.FuelSystemDesignID = FSD.FuelSystemDesignID
                               JOIN Aspiration Asp
                                  ON EC.AspirationID = Asp.AspirationID
                               JOIN CylinderHeadType CHT
                                  ON EC.CylinderHeadTypeID = CHT.CylinderHeadTypeID
                               JOIN FuelType FT
                                  ON EC.FuelTypeID = FT.FuelTypeID
                               JOIN IgnitionSystemType IST
                                  ON EC.IgnitionSystemTypeID = IST.IgnitionSystemTypeID
                               JOIN Mfr EMFR
                                  ON EC.EngineMfrID = EMFR.MfrID
                               JOIN EngineVersion EVer
                                  ON EC.EngineVersionID = EVer.EngineVersionID
                               JOIN PowerOutput PO
                                  ON EC.PowerOutputId = PO.PowerOutputId ) PQEngine
               ON Vehicle.VehicleID = PQEngine.VehicleID

            JOIN ( select STRAIGHT_JOIN
                         VTM.VehicleID,
                         TT.TransmissionTypeName,
                         TNS.TransmissionNumSpeeds,
                         TEC.ElecControlled,
                         Mfr.MfrName,
                         TMC.TransmissionMfrCode
                      from 
                         VehicleToTransmission VTM
                            JOIN Transmission T
                               ON VTM.TransmissionID = T.TransmissionID
                               JOIN TransmissionBase TB
                                  ON T.TransmissionBaseID = TB.TransmissionBaseID
                                  JOIN TransmissionType TT
                                     ON TB.TransmissionTypeID = TT.TransmissionTypeID
                                  JOIN TransmissionNumSpeeds TNS
                                     ON TB.TransmissionNumSpeedsID = TNS.TransmissionNumSpeedsID
                                  JOIN TransmissionControlType TCT
                                     ON TB.TransmissionControlTypeID = TCT.TransmissionControlTypeID
                               JOIN ElecControlled TEC 
                                  ON T.TransmissionElecControlledID = TEC.ElecControlledID
                               JOIN Mfr 
                                  ON T.TransmissionMfrID = Mfr.MfrID
                               JOIN TransmissionMfrCode TMC
                                  ON T.TransmissionMfrCodeID = TMC.TransmissionMfrCodeID ) PQVTrans
               ON Vehicle.VehicleID = PQVTrans.VehicleID

现在,对于笑脸,根据自己的优点预先测试每个PREQUERIES,以确保它们正常工作,并请记下每个查询返回的条目数。我们可能需要进行修改后的查询以获取每辆车的计数,以查看笛卡尔结果可能位于何处并终止服务器内存。对于子查询,我还缩写了表名,以缩短一些可读性。

PQBaseVehicle
PQVTrans
PQEngine
PQBrakes
PQBody
PQBeds
PQSteering

例如,PQSteering,只运行这部分......

SELECT STRAIGHT_JOIN
      VSC.VehicleID,
      ST.SteeringTypeName,
      SS.SteeringSystemName
   FROM
      VehicleToSteeringConfig VSC
         JOIN SteeringConfig SC
            ON VSC.SteeringConfigID = SC.SteeringConfigID
            JOIN SteeringType ST
               ON SC.SteeringConfigID = ST.SteeringTypeID
            JOIN SteeringSystem SS
               ON SC.SteeringSystemID = SS.SteeringSystemID

我出去过夜,明天会检查一下,看看我是否可以帮助进行跟进。