In SQL, is UPDATE always faster than DELETE+INSERT?

前端 未结 15 2180
梦谈多话
梦谈多话 2020-11-29 20:01

Say I have a simple table that has the following fields:

  1. ID: int, autoincremental (identity), primary key
  2. Name: varchar(50), unique, has unique index<
15条回答
  •  遥遥无期
    2020-11-29 20:59

    A bit too late with this answer, but since I faced a similar question, I made a test with JMeter and a MySQL server on same machine, where I have used:

    1. A transaction Controller (generating parent sample) that contained two JDBC Requests: a Delete and an Insert statement
    2. A sepparate JDBC Request containing the Update statement.

    After running the test for 500 loops, I have obtained the following results:

    DEL + INSERT - Average: 62ms

    Update - Average: 30ms

    Results:

提交回复
热议问题