If the table has too many indices, it is better to disable them during update and enable it again after update3.
Instead of updating the table in single shot, break it into groups as shown in the above example.
But in many cases this only provides a modest improvement as each UPDATE operation still requires a round-trip communication with the database server.
In the case where the application server and database server are on different hosts, the round-trip will involve network latency as well.
You say you have 2 tables, but you show the definition for 3 tables. AND (C.column1, C.column2, C.column3) IS DISTINCT FROM (A.column1, B.column2, A.column1 B.column2) clause is optional to avoid empty updates that would not change anything (but still write a new row version at full cost).
You say you are attempting to create a table, but show the code for updating rows within an existing table. If your intent is to insert rows from A B into C, you likely want to use an INSERT statement. @ypercube already gave a basic explanation in his comment.
Consider the following code: The above code updates 10000 rows at a time and the loop continues till @@rowcount has a value greater than zero. Best practices while updating large tables in SQL Server1.
In this article I will demonstrate a fast way to update rows in a large table Consider a table called which has more than 5 millions rows.
Cross table update (also known as correlated update, or multiple table update) in Oracle uses non-standard SQL syntax format (non ANSI standard) to update rows in another table. Update data in table A based on two or more common columns in table B.
The differences in syntax are quite dramatic compared to other database systems like MS SQL Server or My SQL. Updates based on two or more common columns are normally used for tables where multiple columns work together as a primary key (known as composite primary key).
But if there are a large number of rows that require an update, then the overhead of issuing large numbers of UPDATE statements can result in the operation as a whole taking a long time to complete.
The traditional advice for improving performance for multiple UPDATE statements is to “prepare” the required query once, and then “execute” the prepared query once for each row requiring an update.