Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Improving sluggish SQL
Message
From
20/12/1999 11:37:02
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00306158
Message ID:
00306210
Views:
28
Bruce,

>select * from table1;
where keyfield NOT IN;
(select keyfield from table2)

>is not optimizable, and is extremely slow (about 15 minutes or more) for each query. I have tried a SCAN/SEEK, but it is at least as slow or worse, since you're looking for unique keys that don't exist, and therefore must hit every record.

Try using a left join.

select * from table1 left join table2 on table1.keyfield = table2.keyfield
where isnull(table2.keyfield)

This will return only the records from table1 where there is no match in table2.

Cheers
Steve Lea
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform