Deleting millions of rows in MySQL

前端 未结 14 760
春和景丽
春和景丽 2020-12-02 07:05

I recently found and fixed a bug in a site I was working on that resulted in millions of duplicate rows of data in a table that will be quite large even without them (still

14条回答
  •  死守一世寂寞
    2020-12-02 07:48

    DELETE FROM `table`
    WHERE (whatever criteria)
    ORDER BY `id`
    LIMIT 1000
    

    Wash, rinse, repeat until zero rows affected. Maybe in a script that sleeps for a second or three between iterations.

提交回复
热议问题