TerraSamba
Programmer
Guys, I have a query that is executing somewhat slowly ...
Here is the query:
SELECT @strPeriod AS Period,
__QCWhs_W1.WhsShortName,
__QCInput.strWhsProdCode,
__QCInput.strCPostOrig,
SUM(__QCInput.decUnitsOrig) AS decUnitsOrigSum,
SUM(__QCInput.decValuesOrig) AS decValuesOrigSum
INTO dbo.__QCInput_W1
FROM __QCWhs_W1
INNER JOIN
__QCInput ON __QCWhs_W1.sinWhsCodeID = __QCInput.sinWhsCodeID
LEFT OUTER JOIN
__QCPeriods_W1 ON __QCInput.sinPeriodID = __QCPeriods_W1.sinInputPeriodID
GROUP BY
__QCInput.strWhsProdCode,
__QCInput.strCPostOrig,
__QCWhs_W1.WhsShortName
__QCPeriods is a small table (15 recs) and so is __QCWhs_W1 (10 recs). __QCInput is somewhat bigger, about 12 million recs. The result will contain about 3.2 million records.
Does anyone have some optimisation tips? __QCInput is well indexed. But I want to know if I can get more speed moving the joins to the where clause or something ...
Help appreciated !!!
The gap between theory and practice is not as wide in theory as it is in practice.
Here is the query:
SELECT @strPeriod AS Period,
__QCWhs_W1.WhsShortName,
__QCInput.strWhsProdCode,
__QCInput.strCPostOrig,
SUM(__QCInput.decUnitsOrig) AS decUnitsOrigSum,
SUM(__QCInput.decValuesOrig) AS decValuesOrigSum
INTO dbo.__QCInput_W1
FROM __QCWhs_W1
INNER JOIN
__QCInput ON __QCWhs_W1.sinWhsCodeID = __QCInput.sinWhsCodeID
LEFT OUTER JOIN
__QCPeriods_W1 ON __QCInput.sinPeriodID = __QCPeriods_W1.sinInputPeriodID
GROUP BY
__QCInput.strWhsProdCode,
__QCInput.strCPostOrig,
__QCWhs_W1.WhsShortName
__QCPeriods is a small table (15 recs) and so is __QCWhs_W1 (10 recs). __QCInput is somewhat bigger, about 12 million recs. The result will contain about 3.2 million records.
Does anyone have some optimisation tips? __QCInput is well indexed. But I want to know if I can get more speed moving the joins to the where clause or something ...
Help appreciated !!!
The gap between theory and practice is not as wide in theory as it is in practice.