Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to use select... where EXISTS ... ?
Message
From
28/05/2003 11:27:28
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00793069
Message ID:
00793539
Views:
41
Hi Sergey,

Normal IN and EXISTS they are practically equal.

IF you clone pivot table records:

SELECT * FROM ...

IN is faster,

but

SELECT *,1 FROM ...

can do EXISTS faster 5%.

The problem is an other:

IN support correlate expression ( it build one Index on fly )

but

EXISTS not support correlate expression !

Example:

create cursor x1 ( i1 i, c1 c(10) )
for i = 1 to 100000
insert into x1 values ( i, STR( i ) )
endfor

create cursor x2 ( i1 i, c1 c(10) )
for i = 1 to 100000 step 2
insert into x2 values ( i, STR( i ) )
endfor
select * from x1 where i1 IN (SELECT MOD(i1,50000) FROM x2) into cursor x3
select * from x1 where exists (select * from x2 where MOD(x2.i1,50000) = x1.i1) into cursor x3

USE IN x3
USE IN x2
USE IN x1

Then, i can ignore EXISTS and uses only IN on select command ?

Fabio
Previous
Reply
Map
View

Click here to load this message in the networking platform