Condition
year(orders.dOrddate)=year(date()) is not Rusmore optimizable because there's no index on year(dOrddate). You're also on the wrong work area ('ordregl' instead of 'orders') when you execute LOCATE. You can change code as follow
SELECT orders
locate for BETWEEN(dOrddate, DATE(year(date(),01,01)), DATE(year(date(),12,31))) ;
and iordernr = i_ordernr
SELECT-SQL on other hand doesn't use already open tables so currently selected work area has no effect on it.
>Hi,
>
>Can anyone explain me some strange behaviour using Visual Foxpro 7?
>The problem is that i have an application that has several relations
>on a material file and that the file is about 20 mb.
>
>Sometimes when i use the folowing line in code the application
>is consuming all 20 mb from the fileserver to the workstation:
>
>i_ordernr = 1002
>select ordregl
>locate for year(orders.dOrddate)=year(date()) and orders.iordernr = i_ordernr
>
>if found()
> -----
>endif
>
>When i do the following code the network traffic is 50 kilobytes!!! :
>
>i_ordernr = 1002
>select ordregl
>select iordernr from orders into cursor dummy where year(orders.dOrddate)= year(date()) and orders.iordernr = i_ordernr
>
>if _tally > 0
> -----
>endif
>
>
>How can this be?
>dOrddate,iordernr are indexed into a .cdx file
>
>Suggestions?
>
>best regards,
>
>Piet
--sb--