General information
Category:
Databases,Tables, Views, Indexing and SQL syntax
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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only