Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I optimize a SQL Select statement
Message
 
To
30/05/2003 11:40:05
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00794536
Message ID:
00794544
Views:
12
One of the alternatives is NOT to use SQL select.
Let us suppose you have index on fld2search in "related table".
Then you may try someting like:
use "related_table" in 0 order fld2search
sele table2scan
scan
if indexseek(table2scan.keyfield,.t.,"related_table", "fld2search")
sele related_table
skip 1
if fld2search=table2scan.keyfield
* duplicate
endif
.....
endscan

Other approach could be like this:
select fld2search from related_table group by 1 having cnt(*)>1 into curs temp
index on fld2search tag fld2search
sele table2scan
set rela to keyfield into temp
scan for not eof("temp") &&duplicates only
*duplicate
endscan



>I have a SCAN loop with a nested SQL Select statement (to check for duplicates in related table on common field).
>
>The application can take up to 6 seconds to execute SQL Select against table with 223,000 records, which seems very slow to me. In VFP 8.0 doc it says that SQL statements attempt to optimize, and do so if possible, but don't use Rushmore optimization. Is this true? If so, what do I do to speed up this operation?
>
>Fz - Boston MA
Previous
Reply
Map
View

Click here to load this message in the networking platform