user84592
user84592

Reputation: 4882

SQL performance: Is UPDATE faster than INSERT

I must do 10,000 INSERTs, then 10,000 UPDATEs on the inserted rows. I am wondering whether UPDATE in SQL is faster than INSERT or not. Normal simple table with 30 to 50 columns. I am using JDBC.

Upvotes: 1

Views: 1278

Answers (1)

TomTom
TomTom

Reputation: 62093

Forget IDBC - the difference is neglegible.

Theoretically updates CAN be faster, especially if the columns updated are not indexed. Simple reason is that an insert requires the reallocation of space and possibly split / rebalance of indices, while an update that does not contain an index at most requires a reallocation of space (varchar), possibly not even that (fields with fixed length).

Upvotes: 3

Related Questions