1

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.

UltraCommit
  • 1,966
  • 5
  • 38
  • 58
user84592
  • 4,092
  • 6
  • 45
  • 72
  • http://stackoverflow.com/questions/1271641/in-sql-is-update-always-faster-than-deleteinsert http://stackoverflow.com/questions/3895622/is-it-faster-to-update-a-row-or-to-delete-it-and-insert-a-new-one – sdolgy Jun 24 '11 at 05:42
  • 2
    I fail to see why you need to immediately update rows that you already inserted. Why not provide the correct values during insert right away? – a_horse_with_no_name Jun 24 '11 at 06:21

1 Answers1

3

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).

TomTom
  • 1
  • 9
  • 78
  • 143