Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Why sub-select so much slower than CSV list
Message
From
10/12/2009 04:51:11
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
 
To
10/12/2009 04:26:25
Walter Meester
HoogkarspelNetherlands
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01438268
Message ID:
01438350
Views:
54
Hi Walter,

o.k, this is hard to test for a simple SELECT like this one. Maybe I place a UDF in the colum section of the SQL and count.

something like
PUBLIC lnCount
lnCount=0
SELECT * FROM tmpSource WHERE fs1 IN (SELECT t1+MyUDF() FROM tmpFilter) INTO CURSOR tmp
?lnCount

function MyDF
lnCount=lnCount+1
return ''
endfunc
As soon as you place something in the WHERE (especially if related to the outer select) of the inner SELECT this must fail.

But this was not the question.


Agnes
>Hi Agnes,
>
>
>>Sorin,
>>the subselect will be evaluated over and over. In your example for every record in the outer select. So there is a bit of work to do.
>
>AFAIK, that is not correct. The inner select is only executed once and placed in a temp file. Then for each record in the outer select it is searching the temp file for a match. The optimizer in the first approach just does do the opposite: Take each value in the IN clause and search that in the table directly using the index.
>
>AFAICS, the optimizer is not smart enough to see that both cases are equivalent. SQL server might be a bit smarter in this respect.
>
>Walter,
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform