Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Replace vs. Update
Message
From
31/10/2008 11:57:49
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01358644
Message ID:
01358687
Views:
23
This message has been marked as a message which has helped to the initial question of the thread.
>Hi everybody,
>
>If I have a cursor to process which I'm scanning and based on this cursor I need to change (update & insert) several tables (one record per each) is it better (performnce wise) to use
>
>UPDATE where PK = cursor.Field
>
>vs.
>
>if seek(PKField, 'MyTable')
>   replace in myTable
>endif
>
>Assuming all the tables are in buffered 5 mode.
>
>Thanks a lot in advance.

SEEK beats WHERE because SEEK uses http://en.wikipedia.org/wiki/Binary_search and the WHERE clause uses Rushmore Technology.
SET TALK OFF
SET STATUS BAR OFF
USE c:\speed\speed
a=SECONDS()
FOR x = 1 TO 1000
	UPDATE SPEED SET SPD_ID = 5352770 WHERE SPD_ID = 5352770
ENDFOR x
?SECONDS()-m.a
Takes 14.687 on my C: drive
SET ORDER TO TAG IXSPDID
a=SECONDS()
FOR x = 1 TO 1000
	SEEK 5352770
	REPLACE SPD_ID WITH 5352770
ENDFOR x
?SECONDS()-m.a
Takes 0.250 seconds.
Previous
Reply
Map
View

Click here to load this message in the networking platform