Home >Database >Mysql Tutorial >How to quickly delete large amounts of data in mysql
Mysql quick way to delete a large amount of data: first create a temporary table, the table structure is the same as the original table structure; then insert the data that needs to be retained into the temporary table, and drop the original table; finally, rename the temporary table The original table name will do.
Mysql quick way to delete large amounts of data:
Option 1,
Use delete directly
Because the delete execution speed is proportional to the number of indexes, if there are many indexes in the table, using delete will take hours or even days
Option 2,
(1) Create a temporary table, the table structure is the same as the original table structure
(2) Insert the data that needs to be retained into the temporary table Medium
(3) Drop the original table
(4) Rename the temporary table to the original table name
After testing, dropping the table is generally time-consuming Within 3 seconds
The main time-consuming step of this solution is the second step. If the amount of data that needs to be retained is not large, this solution is the best solution
Update More related free learning recommendations: mysql tutorial(Video)
The above is the detailed content of How to quickly delete large amounts of data in mysql. For more information, please follow other related articles on the PHP Chinese website!