Deleting millions of rows in MySQL

前端 未结 14 788
春和景丽
春和景丽 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 08:00

    According to the mysql documentation, TRUNCATE TABLE is a fast alternative to DELETE FROM. Try this:

    TRUNCATE TABLE table_name

    I tried this on 50M rows and it was done within two mins.

    Note: Truncate operations are not transaction-safe; an error occurs when attempting one in the course of an active transaction or active table lock

提交回复
热议问题