C
Cascot
I have a select query which is acting very strangely. On my local
development system it was fine but during recent changes (no changes to
this specific query or the tables it queries) I noticed that in the new
version of the system the query was running slowly. Removing a criteria
of "False" from a non-indexed Yes/No type field speeded it up, but when
I replicated this change on the client site it made no difference -
still slow. I removed the criteria "True" from the other boolean field
included in the query and it displayed it's resultys in an instant. I
have tried redoing the query from scratch, importing all object into a
new mdb, etc all to no avail.
Can anyone suggest what could be causing this - runing very slowly, but
when I remove both of the "True" & "False" criteria it completes in a
flash as it should. Here is the SQL:
SELECT InvoiceHdr.InvoiceHdrId AS PrnInvoiceHdrId, InvoiceHdr.PrintNow,
TelephoneNo.Description, Call.CallTime,
IIf(nz([CarrierDestination].[Description],"")="",[Destination].[PrintDescription],[CarrierDestination].[Description])
AS Destination, Call.CallTelNo, Call.CallDuration,
SecondsToHHMMSS([CallDuration]) AS CallDurationB, Call.CallCost,
Call.CallDate, TelephoneNo.ExcludeFromItemisation
FROM Organisation INNER JOIN ((TelephoneNo INNER JOIN (InvoiceHdr INNER
JOIN (CarrierDestination RIGHT JOIN Call ON
CarrierDestination.CarrierDestinationId = Call.CarrierDestinationId) ON
InvoiceHdr.InvoiceHdrId = Call.InvoiceHdrId) ON
TelephoneNo.TelephoneNoId = Call.TelephoneNoId) INNER JOIN Destination
ON Call.DestinationId = Destination.DestinationId) ON
Organisation.OrganisationId = InvoiceHdr.OrganisationId
WHERE (((InvoiceHdr.PrintNow)=True) AND
((Call.CallCost)>=[ItemisationLevel] Or (Call.CallCost)<0) AND
((TelephoneNo.ExcludeFromItemisation)=False));
If I was doing this today I would consider replacing the NZ with a
Len([Fieldname])=0.
There is a call to a function called SecondsToHHMMSS, but this works
well and removing it does not noticeably speed up the query, it is only
removal of the criteria on the boolean fields which does the trick.
Any suggestions would be much appreciated.
development system it was fine but during recent changes (no changes to
this specific query or the tables it queries) I noticed that in the new
version of the system the query was running slowly. Removing a criteria
of "False" from a non-indexed Yes/No type field speeded it up, but when
I replicated this change on the client site it made no difference -
still slow. I removed the criteria "True" from the other boolean field
included in the query and it displayed it's resultys in an instant. I
have tried redoing the query from scratch, importing all object into a
new mdb, etc all to no avail.
Can anyone suggest what could be causing this - runing very slowly, but
when I remove both of the "True" & "False" criteria it completes in a
flash as it should. Here is the SQL:
SELECT InvoiceHdr.InvoiceHdrId AS PrnInvoiceHdrId, InvoiceHdr.PrintNow,
TelephoneNo.Description, Call.CallTime,
IIf(nz([CarrierDestination].[Description],"")="",[Destination].[PrintDescription],[CarrierDestination].[Description])
AS Destination, Call.CallTelNo, Call.CallDuration,
SecondsToHHMMSS([CallDuration]) AS CallDurationB, Call.CallCost,
Call.CallDate, TelephoneNo.ExcludeFromItemisation
FROM Organisation INNER JOIN ((TelephoneNo INNER JOIN (InvoiceHdr INNER
JOIN (CarrierDestination RIGHT JOIN Call ON
CarrierDestination.CarrierDestinationId = Call.CarrierDestinationId) ON
InvoiceHdr.InvoiceHdrId = Call.InvoiceHdrId) ON
TelephoneNo.TelephoneNoId = Call.TelephoneNoId) INNER JOIN Destination
ON Call.DestinationId = Destination.DestinationId) ON
Organisation.OrganisationId = InvoiceHdr.OrganisationId
WHERE (((InvoiceHdr.PrintNow)=True) AND
((Call.CallCost)>=[ItemisationLevel] Or (Call.CallCost)<0) AND
((TelephoneNo.ExcludeFromItemisation)=False));
If I was doing this today I would consider replacing the NZ with a
Len([Fieldname])=0.
There is a call to a function called SecondsToHHMMSS, but this works
well and removing it does not noticeably speed up the query, it is only
removal of the criteria on the boolean fields which does the trick.
Any suggestions would be much appreciated.