Hi Everyone,
I have the following query with a few left joins which was taking about 5 secs to open and now takes 40 secs? The only thing I have changed are the queries that they are based on but they run and open instanteously! Even if I change those queries to make-table queries and then base the query below on the tables it still takes 40 secs to open. I don't understand why it's all of a sudden so slow. This query is used in a report hence the users have been complaining about how slow it has become but I just don't understand why it has happened. ANy advice would be greatly appreciated.
many thanks in advance,
GPM
SELECT A.CustomerNo, A.Name, A.ItemNo, A.Description, A.[Description 2], nz([TotalInvoiceQty])-Nz([TotalCreditQty]) AS ActualQty, B.TotalBudgetQty, nz([TotalInvoiceQty])-Nz([TotalCreditQty])-Nz([totalBudgetQty]) AS QtyVariance, Nz([TotalInvoiceAmt])-Nz([totalCreditAmt]) AS ActualAmount, IIf(Nz([TotalInvoiceAmt])-Nz([totalCreditAmt])=0,0,(Nz([TotalInvoiceAmt])-Nz([totalCreditAmt]))/(nz([TotalInvoiceQty])-Nz([TotalCreditQty]))) AS AvgPrice, Nz([totalInvoiceAmountLCY])-nz([totalCreditAmountLCY]) AS ActualAmountLCY, IIf(Nz([TotalInvoiceAmt])-Nz([totalCreditAmt])=0,0,(Nz([totalInvoiceamountLCY])-nz([totalCreditAmountLCY]))/nz([TotalInvoiceQty])-Nz([TotalCreditQty])) AS AvgPriceLCY
FROM ((qryCustomerItem AS A LEFT JOIN qrySalesInvoice AS I ON A.CustomerItemNo = I.CustomerItemNo) LEFT JOIN qrySalesBudget AS B ON A.CustomerItemNo = B.CustomerItemNo) LEFT JOIN qrySalesCredit AS C ON A.CustomerItemNo = C.CustomerItemNo
WHERE (((Trim([C].[CustomerItemNo] & .[CustomerItemNo] & .[CustomerItemNo] & ""))<>""))
ORDER BY A.CustomerNo;
I have the following query with a few left joins which was taking about 5 secs to open and now takes 40 secs? The only thing I have changed are the queries that they are based on but they run and open instanteously! Even if I change those queries to make-table queries and then base the query below on the tables it still takes 40 secs to open. I don't understand why it's all of a sudden so slow. This query is used in a report hence the users have been complaining about how slow it has become but I just don't understand why it has happened. ANy advice would be greatly appreciated.
many thanks in advance,
GPM
SELECT A.CustomerNo, A.Name, A.ItemNo, A.Description, A.[Description 2], nz([TotalInvoiceQty])-Nz([TotalCreditQty]) AS ActualQty, B.TotalBudgetQty, nz([TotalInvoiceQty])-Nz([TotalCreditQty])-Nz([totalBudgetQty]) AS QtyVariance, Nz([TotalInvoiceAmt])-Nz([totalCreditAmt]) AS ActualAmount, IIf(Nz([TotalInvoiceAmt])-Nz([totalCreditAmt])=0,0,(Nz([TotalInvoiceAmt])-Nz([totalCreditAmt]))/(nz([TotalInvoiceQty])-Nz([TotalCreditQty]))) AS AvgPrice, Nz([totalInvoiceAmountLCY])-nz([totalCreditAmountLCY]) AS ActualAmountLCY, IIf(Nz([TotalInvoiceAmt])-Nz([totalCreditAmt])=0,0,(Nz([totalInvoiceamountLCY])-nz([totalCreditAmountLCY]))/nz([TotalInvoiceQty])-Nz([TotalCreditQty])) AS AvgPriceLCY
FROM ((qryCustomerItem AS A LEFT JOIN qrySalesInvoice AS I ON A.CustomerItemNo = I.CustomerItemNo) LEFT JOIN qrySalesBudget AS B ON A.CustomerItemNo = B.CustomerItemNo) LEFT JOIN qrySalesCredit AS C ON A.CustomerItemNo = C.CustomerItemNo
WHERE (((Trim([C].[CustomerItemNo] & .[CustomerItemNo] & .[CustomerItemNo] & ""))<>""))
ORDER BY A.CustomerNo;