Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any way to speed this up?
Message
 
To
30/10/2007 13:48:26
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01265099
Message ID:
01265119
Views:
8
>>>This is part of an application originally written in vfp5; it runs slower in vfp9.
>>>Any idea on how to speed it up? (All fields involved in joins, where clauses, etc. have indexes...)
>>>
>>>SELECT VAL(Customer.code) AS valcode, Invhead.*, Ordhead.location,;
>>>  Ordhead.entered, Ordhead.priorityorder, Ordhead.customerpo,;
>>>  Ordhead.daterequired, Ordhead.comm1, Ordhead.comm2, Ordhead.comm3,;
>>>  Ordhead.terms, Customer.name, Customer.code, Customer.creditlmt,;
>>>  Customer.einnumber, Customer.specialdisc, Customer.dollarsuse,;
>>>  Ordhead.customerid, Customer.country AS custcountry,;
>>>  Prodqty.totordered, Prodqty.totallocated, Prodqty.totshipped, .F. AS ok,;
>>>  Rdytoship.rdytoship, Shipped.shipped, Prodqty.specialord,;
>>>  ALLTRIM(STR(Ordhead.orderid))+IIF(Ordhead.sbo,"B"," ") AS dispordno,;
>>>  Customer.onhold;
>>> FROM ;
>>>     frantisi!invhead ;
>>>    INNER JOIN frantisi!ordhead ;
>>>   ON  Invhead.orderid = Ordhead.orderid ;
>>>    INNER JOIN frantisi!shipped ;
>>>   ON  Ordhead.orderid = Shipped.orderid ;
>>>    INNER JOIN frantisi!rdytoship ;
>>>   ON  Invhead.invoiceno = Rdytoship.invoiceno ;
>>>    INNER JOIN frantisi!customer ;
>>>   ON  Customer.customerid = Ordhead.customerid ;
>>>    INNER JOIN frantisi!prodqty ;
>>>   ON  Ordhead.orderid = Prodqty.orderid;
>>> WHERE ( ( (  EMPTY(?ldDateReqd) ;
>>>   OR  Ordhead.daterequired <= ( ?ldDateReqd ) );
>>>   OR  NOT (EMPTY(Invhead.picked) ) );
>>>   AND  (  ( ?lnLocation ) = ( 0 );
>>>   OR  Ordhead.location = ( ?lnLocation ) ) );
>>>   AND  EMPTY(dispatchdate) ;
>>> ORDER BY 1, Ordhead.priorityorder DESC, Invhead.invoiceno ;
>>>into cursor dispatch
>>>
>>
>>Make sure the codepage for the tables involved is the same as the codepage when you open the view. (CPDBF() = CPCURRENT())
>>
>>Use SYS(3054) to see how VFP is handling this query.
>>
>>Tamar
>
>
>>> WHERE ( ( (  EMPTY(?ldDateReqd) ;
>>>   OR  Ordhead.daterequired <= ( ?ldDateReqd ) );
>>>   OR  NOT (EMPTY(Invhead.picked) ) );
>>>   AND  (  ( ?lnLocation ) = ( 0 );
>>>   OR  Ordhead.location = ( ?lnLocation ) ) );
>>>   AND  EMPTY(dispatchdate) ;
>
>
>
>Is there a reason that you are checking for such things as EMPTY(?ldDateReqd) and ?lnLocationID = 0? These are parameters that are being passed into the query, so checking their values in the query is not obvious and perhaps not neccessary...
>
>Perhaps I am missing something...
>
>Carsten

Not true,
The query doesn't CHECKING if the parameter is empty or not, but the meaning of this is:
If I pass EMPTY(ldDateReqd) I want ALL records no matter of the value of Ordhead.daterequired, if I pass nLocation=0 I want ALL records no matter of Ordhead.location value. Par example(Ignoring the rest of the WHERE clause):
*** I want ALL records no matter the location and daterequired 
ldDateReqd = {}
lnLocation = 0
REQUERY(ViewHere)

*** I want ALL records no matter the location but for specific period (OK not period :o))
ldDateReqd = DATE()-50
lnLocation = 0
REQUERY(ViewHere)

*** I want ALL records for specific location
ldDateReqd = {}
lnLocation = 1
REQUERY(ViewHere)

*** And finally I want ALL records for specific location and specific dates
ldDateReqd = DATE()-50
lnLocation = 1
REQUERY(ViewHere)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform