General information
Category:
Coding, syntax & commands
Hello Kevin
This is the line from the help file I use in deciding to use REPLACE or UPDATE.
Unlike REPLACE, UPDATE - SQL uses record locking when updating multiple records in a table opened for shared access. This reduces record contention in multiuser situations, but may reduce performance. For maximum performance, open the table for exclusive use or use FLOCK( ) to lock the table.
When I need speed I use REPLACE.
If I think the records I am going to update may be locked I may use UPDATE.
However now that I do most things via VIEWS this situtation does not happen very oftens. For manipulation of my VIEWS prior to committing changes I almost always use replace to get the speed benefit.
>I am modifying an application that has many instances of multiple
>REPLACE commands to update tables, such as
>
>
>replace field1 with "value1"
>replace field2 with "value2"
>replace field3 with "value3"
>
>
>I want to speed this application up. So I considered:
>
>UPDATE MyTable;
> SET Field1 = "Value1";
> Field2 = "Value2"
> Field3 = "Value3"
>
>
>Since REPLACE starts at the first record, the 3 separate REPLACE commands
>therefore make 3 passes through the table, while the SQL Update goes through
>the table only once.
>
>However, the Hackers Guide says the SQL Update is slower than REPLACE. Isnt
>REPLACE 'old school' and SQL 'optimized'?
>
>What are the Pros and Cons of each method?
>
>Thanks
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