Hi,
I am a new database developer and would appreciate some advice on
improving the efficiency of my database.
The code below is an example of one of the more complex queries in the
database (very basic in the scheme of things).
Can anyone offer advice in improving the structure considering this
database resides on a network with limited bandwidth. The query runs
fine with 2 weeks worth of data (1000 records), however, I am
concerned that the query will slow to a crawl once the database grows
in size (eventually containing 50,000+)
It is not possible, in the short term, to modify the structure of the
underlying queries & tables. Also, the data must be fully compatible
with excel (so no "nz" functions or the like).
Any feedback is much appreciated.
SELECT qryDataDaily.FY , qryDataDaily.DC , qryDataDaily.My Date,
qryDataDaily.We ek, qryDataDaily.Pe riod, qryDataDaily.Mo nthYear,
qryDataDaily.Pe riodName, qryINindent.InI ndentTEUsWater,
qryINindent.InI ndentTEUsYard, qryFCin.fcINteu syard,
qryINindent.InI ndentTEUsReceiv ed, qryFCin.fcINteu sreceived,
qryINindent.InI ndentPalletsDev anned, qryFCin.fcInind entpallets,
qryINlocal.InLo calPalletsRecei ved, qryFCin.fcInloc alpallets,
[InIndentPallets Devanned]+[InLocalPalletsR eceived] AS
InTotalPalletsR eceived, [fcInindentpalle ts]+[fcInlocalpallet s] AS
fcINtotalPallet s, qryINDIRECTfina ncials.Received Value,
qryWHoffice.WHA llocations, qryWHoffice.WHS hortSweep,
iif([OUTcmergeCarton sSorted]>0,[OUTcmergeCarton sSorted],0)+iif([WHncSortOMs]>0,[WHncSortOMs],0)+iif([WHsecurityOMs]>0,[WHsecurityOMs],0)
AS TotalOMsProcess ed, qryFCwh!fcWHcOm s+qryFCwh!fcWHn cOMs AS
fcOMsProcessed, (iif(qryOUTcWra p!OUTcWrapPalle ts>0,qryOUTcWra p!OUTcWrapPalle ts,0))+(iif(qry WHncSort!WHncSo rtPalletsBuilt> 0,qryWHncSort!W HncSortPalletsB uilt,0))
AS TotalPalletsBui lt, qryINDIRECTfina ncials.Producti onValue,
qryWHoffice.WHO rderbank, qryOUTdDespatch .OutDespTotalPa llets,
qryFCout.fcOutp allets, qryWHinvCC.WHin vPalletsDC,
qryWHinvCC.WHin vPallets3PL, qryWHinvCC.WHin vPalletsonhand,
qryINDIRECTfina ncials.SOHvalue ,
qryOUTdDespatch .OutDespTotalPa lletsDock, qryFCretail.fcC ostofSales
FROM ((((((((((((((q ryDataDaily LEFT JOIN qryINindent ON
(qryDataDaily.M yDate=qryINinde nt.MyDate) AND
(qryDataDaily.D C=qryINindent.D C)) LEFT JOIN qryINlocal ON
(qryDataDaily.M yDate=qryINloca l.MyDate) AND
(qryDataDaily.D C=qryINlocal.DC )) LEFT JOIN qryOUTcMerge ON
(qryDataDaily.M yDate=qryOUTcMe rge.MyDate) AND
(qryDataDaily.D C=qryOUTcMerge. DC)) LEFT JOIN qryWHncSort ON
(qryDataDaily.M yDate=qryWHncSo rt.MyDate) AND
(qryDataDaily.D C=qryWHncSort.D C)) LEFT JOIN qryWHsecurity ON
(qryDataDaily.M yDate=qryWHsecu rity.MyDate) AND
(qryDataDaily.D C=qryWHsecurity .DC)) LEFT JOIN qryOUTcWrap ON
(qryDataDaily.M yDate=qryOUTcWr ap.MyDate) AND
(qryDataDaily.D C=qryOUTcWrap.D C)) LEFT JOIN qryOUTdDespatch ON
(qryDataDaily.M yDate=qryOUTdDe spatch.MyDate) AND
(qryDataDaily.D C=qryOUTdDespat ch.DC)) LEFT JOIN qryINoffice ON
(qryDataDaily.M yDate=qryINoffi ce.MyDate) AND
(qryDataDaily.D C=qryINoffice.D C)) LEFT JOIN qryWHoffice ON
(qryDataDaily.M yDate=qryWHoffi ce.MyDate) AND
(qryDataDaily.D C=qryWHoffice.D C)) LEFT JOIN qryWHinvCC ON
(qryDataDaily.M yDate=qryWHinvC C.MyDate) AND
(qryDataDaily.D C=qryWHinvCC.DC )) LEFT JOIN qryFCout ON
(qryDataDaily.D C=qryFCout.DC) AND
(qryDataDaily.M yDate=qryFCout. MyDate)) LEFT JOIN qryFCin ON
(qryDataDaily.D C=qryFCin.DC) AND (qryDataDaily.M yDate=qryFCin.M yDate))
LEFT JOIN qryFCretail ON (qryDataDaily.D C=qryFCretail.D C) AND
(qryDataDaily.M yDate=qryFCreta il.MyDate)) LEFT JOIN qryFCwh ON
(qryDataDaily.D C=qryFCwh.DC) AND (qryDataDaily.M yDate=qryFCwh.M yDate))
LEFT JOIN qryINDIRECTfina ncials ON
(qryDataDaily.D C=qryINDIRECTfi nancials.DC) AND
(qryDataDaily.M yDate=qryINDIRE CTfinancials.My Date);
I am a new database developer and would appreciate some advice on
improving the efficiency of my database.
The code below is an example of one of the more complex queries in the
database (very basic in the scheme of things).
Can anyone offer advice in improving the structure considering this
database resides on a network with limited bandwidth. The query runs
fine with 2 weeks worth of data (1000 records), however, I am
concerned that the query will slow to a crawl once the database grows
in size (eventually containing 50,000+)
It is not possible, in the short term, to modify the structure of the
underlying queries & tables. Also, the data must be fully compatible
with excel (so no "nz" functions or the like).
Any feedback is much appreciated.
SELECT qryDataDaily.FY , qryDataDaily.DC , qryDataDaily.My Date,
qryDataDaily.We ek, qryDataDaily.Pe riod, qryDataDaily.Mo nthYear,
qryDataDaily.Pe riodName, qryINindent.InI ndentTEUsWater,
qryINindent.InI ndentTEUsYard, qryFCin.fcINteu syard,
qryINindent.InI ndentTEUsReceiv ed, qryFCin.fcINteu sreceived,
qryINindent.InI ndentPalletsDev anned, qryFCin.fcInind entpallets,
qryINlocal.InLo calPalletsRecei ved, qryFCin.fcInloc alpallets,
[InIndentPallets Devanned]+[InLocalPalletsR eceived] AS
InTotalPalletsR eceived, [fcInindentpalle ts]+[fcInlocalpallet s] AS
fcINtotalPallet s, qryINDIRECTfina ncials.Received Value,
qryWHoffice.WHA llocations, qryWHoffice.WHS hortSweep,
iif([OUTcmergeCarton sSorted]>0,[OUTcmergeCarton sSorted],0)+iif([WHncSortOMs]>0,[WHncSortOMs],0)+iif([WHsecurityOMs]>0,[WHsecurityOMs],0)
AS TotalOMsProcess ed, qryFCwh!fcWHcOm s+qryFCwh!fcWHn cOMs AS
fcOMsProcessed, (iif(qryOUTcWra p!OUTcWrapPalle ts>0,qryOUTcWra p!OUTcWrapPalle ts,0))+(iif(qry WHncSort!WHncSo rtPalletsBuilt> 0,qryWHncSort!W HncSortPalletsB uilt,0))
AS TotalPalletsBui lt, qryINDIRECTfina ncials.Producti onValue,
qryWHoffice.WHO rderbank, qryOUTdDespatch .OutDespTotalPa llets,
qryFCout.fcOutp allets, qryWHinvCC.WHin vPalletsDC,
qryWHinvCC.WHin vPallets3PL, qryWHinvCC.WHin vPalletsonhand,
qryINDIRECTfina ncials.SOHvalue ,
qryOUTdDespatch .OutDespTotalPa lletsDock, qryFCretail.fcC ostofSales
FROM ((((((((((((((q ryDataDaily LEFT JOIN qryINindent ON
(qryDataDaily.M yDate=qryINinde nt.MyDate) AND
(qryDataDaily.D C=qryINindent.D C)) LEFT JOIN qryINlocal ON
(qryDataDaily.M yDate=qryINloca l.MyDate) AND
(qryDataDaily.D C=qryINlocal.DC )) LEFT JOIN qryOUTcMerge ON
(qryDataDaily.M yDate=qryOUTcMe rge.MyDate) AND
(qryDataDaily.D C=qryOUTcMerge. DC)) LEFT JOIN qryWHncSort ON
(qryDataDaily.M yDate=qryWHncSo rt.MyDate) AND
(qryDataDaily.D C=qryWHncSort.D C)) LEFT JOIN qryWHsecurity ON
(qryDataDaily.M yDate=qryWHsecu rity.MyDate) AND
(qryDataDaily.D C=qryWHsecurity .DC)) LEFT JOIN qryOUTcWrap ON
(qryDataDaily.M yDate=qryOUTcWr ap.MyDate) AND
(qryDataDaily.D C=qryOUTcWrap.D C)) LEFT JOIN qryOUTdDespatch ON
(qryDataDaily.M yDate=qryOUTdDe spatch.MyDate) AND
(qryDataDaily.D C=qryOUTdDespat ch.DC)) LEFT JOIN qryINoffice ON
(qryDataDaily.M yDate=qryINoffi ce.MyDate) AND
(qryDataDaily.D C=qryINoffice.D C)) LEFT JOIN qryWHoffice ON
(qryDataDaily.M yDate=qryWHoffi ce.MyDate) AND
(qryDataDaily.D C=qryWHoffice.D C)) LEFT JOIN qryWHinvCC ON
(qryDataDaily.M yDate=qryWHinvC C.MyDate) AND
(qryDataDaily.D C=qryWHinvCC.DC )) LEFT JOIN qryFCout ON
(qryDataDaily.D C=qryFCout.DC) AND
(qryDataDaily.M yDate=qryFCout. MyDate)) LEFT JOIN qryFCin ON
(qryDataDaily.D C=qryFCin.DC) AND (qryDataDaily.M yDate=qryFCin.M yDate))
LEFT JOIN qryFCretail ON (qryDataDaily.D C=qryFCretail.D C) AND
(qryDataDaily.M yDate=qryFCreta il.MyDate)) LEFT JOIN qryFCwh ON
(qryDataDaily.D C=qryFCwh.DC) AND (qryDataDaily.M yDate=qryFCwh.M yDate))
LEFT JOIN qryINDIRECTfina ncials ON
(qryDataDaily.D C=qryINDIRECTfi nancials.DC) AND
(qryDataDaily.M yDate=qryINDIRE CTfinancials.My Date);
Comment