C
Candy
The report using a crosstab query as record sources is very slow. It could
take hours to generate one report. There are 3 queries:qUniCurrSche
(*Union),
qcartJobOpers (*cartesian), and qxtbOperSchedule (*crosstab), the one
bounded with the report is the qxtbOperSchedule. I've listed the SQL code as
following. Any advice for speeding up will be appreciated.
qUniCurrSche:
SELECT DDue,JobNo,dOrder, "CUT" as Operation, Cut_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "NIT" as Operation, NIT_S as OperDate
FROM jobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "MAN" as Operation, Man_S as OperDate
FROM jobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "DIS" as Operation, Dis_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL SELECT DDue,JobNo,dOrder, "EMB" as Operation, EMB_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "OE1" as Operation, OE1_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "OE2" as Operation, OE2_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "PRT1" as Operation, PRT1_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "PRT2" as Operation, PRT2_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "BUN1" as Operation, BUN1_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "BUN2" as Operation, BUN2_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "INW" as Operation, INW_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "SUB" as Operation, SUB_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL SELECT DDue,JobNo,dOrder, "QC" as Operation, QC_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
ORDER BY dDue;
qcartJobOpers:
SELECT quniCurrSche.ddue, quniCurrSche.dOrder, quniCurrSche.JobNo,
quniCurrSche.Operation, quniCurrSche.OperDate, tblAllDates.theDate
FROM tblAllDates, quniCurrSche
WHERE (((tblAllDates.theDate) Between [OperDate] And (SELECT
Max(OperDate)+1
FROM quniCurrSche j
WHERE (j.JobNo = quniCurrSche.JobNo AND j.OperDate <
quniCurrSche.OperDate) ) )) AND
tblAllDates.theDate >= quniCurrSche.dOrder And
(Year(quniCurrSche.OperDate) >2000)
ORDER BY quniCurrSche.ddue, tblAllDates.theDate;
qxtbOperSchedule:
TRANSFORM First(qcartJobOpers.Operation) AS FirstOfOperation
SELECT Year([TheDate]) AS Yr, DatePart("ww",[TheDate]-1) AS WeekNum,
qcartJobOpers.ddue, qcartJobOpers.JobNo
FROM qcartJobOpers
GROUP BY Year([TheDate]), DatePart("ww",[TheDate]-1), qcartJobOpers.ddue,
qcartJobOpers.JobNo
PIVOT Format([TheDate],"dddd") In
("Monday","Tuesday","Wednesday","Thursday","Friday");
take hours to generate one report. There are 3 queries:qUniCurrSche
(*Union),
qcartJobOpers (*cartesian), and qxtbOperSchedule (*crosstab), the one
bounded with the report is the qxtbOperSchedule. I've listed the SQL code as
following. Any advice for speeding up will be appreciated.
qUniCurrSche:
SELECT DDue,JobNo,dOrder, "CUT" as Operation, Cut_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "NIT" as Operation, NIT_S as OperDate
FROM jobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "MAN" as Operation, Man_S as OperDate
FROM jobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "DIS" as Operation, Dis_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL SELECT DDue,JobNo,dOrder, "EMB" as Operation, EMB_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "OE1" as Operation, OE1_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "OE2" as Operation, OE2_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "PRT1" as Operation, PRT1_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "PRT2" as Operation, PRT2_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "BUN1" as Operation, BUN1_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "BUN2" as Operation, BUN2_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "INW" as Operation, INW_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL
SELECT DDue,JobNo,dOrder, "SUB" as Operation, SUB_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
UNION ALL SELECT DDue,JobNo,dOrder, "QC" as Operation, QC_S as OperDate
FROM JobPath
WHERE (DIS_A < DateValue('01/01/2000'))
ORDER BY dDue;
qcartJobOpers:
SELECT quniCurrSche.ddue, quniCurrSche.dOrder, quniCurrSche.JobNo,
quniCurrSche.Operation, quniCurrSche.OperDate, tblAllDates.theDate
FROM tblAllDates, quniCurrSche
WHERE (((tblAllDates.theDate) Between [OperDate] And (SELECT
Max(OperDate)+1
FROM quniCurrSche j
WHERE (j.JobNo = quniCurrSche.JobNo AND j.OperDate <
quniCurrSche.OperDate) ) )) AND
tblAllDates.theDate >= quniCurrSche.dOrder And
(Year(quniCurrSche.OperDate) >2000)
ORDER BY quniCurrSche.ddue, tblAllDates.theDate;
qxtbOperSchedule:
TRANSFORM First(qcartJobOpers.Operation) AS FirstOfOperation
SELECT Year([TheDate]) AS Yr, DatePart("ww",[TheDate]-1) AS WeekNum,
qcartJobOpers.ddue, qcartJobOpers.JobNo
FROM qcartJobOpers
GROUP BY Year([TheDate]), DatePart("ww",[TheDate]-1), qcartJobOpers.ddue,
qcartJobOpers.JobNo
PIVOT Format([TheDate],"dddd") In
("Monday","Tuesday","Wednesday","Thursday","Friday");