問題是微信群里一伙計提的
`mysql truncate 空表都需要3 4秒,要優化解決`
一開始覺得這莫名其妙,因為作這種操作的都是后台運維,不是實時的對外服務,運維又不差這3秒
其反應truncate表時 別的所有業務都阻塞
查看還真是個問題
官方也有說明
https://dev.mysql.com/doc/refman/8.0/en/truncate-table.html
In MySQL 5.7 and earlier, on a system with a large buffer pool and innodb_adaptive_hash_index enabled, a TRUNCATE TABLE operation could cause a temporary drop in system performance due to an LRU scan that occurred when removing the table's adaptive hash index entries (Bug #68184). The remapping of TRUNCATE TABLE to DROP TABLE and CREATE TABLE in MySQL 8.0 avoids the problematic LRU scan.
解決方式是,測試用的表和線上的庫隔離,或者升級mysql到8.0
原本 truncate操作 就不該在線上服務器發生