MySQL performance DELETE or UPDATE?

前端 未结 5 1764
旧巷少年郎
旧巷少年郎 2021-02-14 22:14

I have a MyISAM table with more than 10^7 rows. When adding data to it, I have to update ~10 rows at the end. Is it faster to delete them and then insert the new ones, or is it

5条回答
  •  轮回少年
    2021-02-14 23:20

    It is faster to update. You can also use INSERT ON DUPLICATE KEY UPDATE

    INSERT INTO table (a,b,c) VALUES (1,2,3)
      ON DUPLICATE KEY UPDATE c=c+1;
    

    For more details read update documentation

提交回复
热议问题