Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Bad performance
Message
From
30/01/2002 08:57:12
 
 
To
29/01/2002 13:21:29
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00612305
Message ID:
00612651
Views:
29
>SELECT * FROM PRO_SCHT INTO CURSOR PROSCHT WHERE ALLTRIM(PRO_SCHT.SPFLAG)="*"
>SELECT 0000000000.000 AS CNTRANGE ,* FROM proscht a INTO DBF &pscht where EXISTS(SELECT * FROM PROD_TRAN b WHERE (a.p_number=b.p_number AND ALLTRIM(b.TRANNUMBER)=ALLTRIM(m.trannumber)))
>

I think your problem has to do with the EXISTS subquery. When you use EXISTS and reference fields from the main query in the subquery (that's called a "correlated subquery"), FoxPro has to run the subquery for each record in the main query. If you can rewrite it using IN and a subquery that's not correlated, it should speed up. And the good news is that any EXISTS subquery can be rewritten as an IN subquery.

WHERE a.p_number + ALLTRIM(a.TRANNUMBER) IN ;
(SELECT b.p_number + ALLTRIM(m.trannumber) FROM PROD_TRAN b)

Of course, you have to make sure the expression is all character and will match correctly.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform