Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Very slow SQL Update even when index exists
Message
From
08/12/2006 17:53:50
 
 
To
07/12/2006 20:25:03
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01174680
Message ID:
01176302
Views:
7
>>This is the way I decided to write it. Not the most elegant way but runs really fast; .04 seconds to update 200 records. I am building a string of keys. mk_ivinvt holds "AAAAA","BBBBB", etc. up to 120 keys at a time.
>>
>>My question now is: Why the heck does
IN (SELECT K_IVINVT FROM C_CHNG)
take the same 12-15 seconds as the original query.
>>
>>Where using
in (<<mk_ivinvt>>)
take only .04 seconds???? It seems they should both be the same but then, as we all know, software works in strange and mysterious ways.
>>
>
>Hi John,
>
>The IN() is somewhat similar to a join (more than one table is involved) and, as I mentioned before, a join can't be optimized with indexes on a table, which is the target for the UPDATE. The IN (), on the other hand, is a filter condition (only one table is involved) and it can be optimized with an index.
>
>Thanks,
>Aleksey.

I disagree.
IN (SELECT FROM listTable without a WHERE) is not similar to a join, and you ( if want ) can optimize the UPDATE as the IN ()
Of course, if RECCOUNT(listTable) > RECCOUNT(updateTable) the scan of updateTable can to be faster.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform