批量删除2000w数据
使用delete from table太慢
//DELIMITER DROP PROCEDURE if EXISTS deleteManyTable; create PROCEDURE deleteManyTable() BEGIN DECLARE i int; set i=1; while i<2001 DO DELETE FROM `f_log` WHERE (`id` >95000000) ORDER BY `id` LIMIT 10000; SELECT SLEEP(0.5); set i=i+1; end while; END; //DELIMITER CALL deleteManyTable();
参考文献:
http://mysql.rjweb.org/doc.php/deletebig
微信公众号: 架构师日常笔记 欢迎关注!