A large number of mysql data deletion, slow problem

Requirement: I have 100W data and want to delete 30W data, the order is not continuous, delete according to where condition.

General writing: delete from table1 where XXX; This way the deletion efficiency is relatively low

Advanced writing method: delete in batches. Delete 1W pieces of data each time to reduce the size of the transaction. Improve efficiency

Ultimate way of writing: We can change the way of thinking and insert the data to be retained into the temporary table. Then use this temporary table. This is more efficient.

Welcome to leave a message and exchange.

Guess you like

Origin blog.csdn.net/qq_37570710/article/details/131473197