`mysql truncate 空表都需要3 4秒,要优化解决`
一开始觉得这莫名其妙,因为作这种操作的都是后台运维,不是实时的对外服务,运维又不差这3秒
其反应truncate表时 别的所有业务都阻塞
查看还真是个问题
官方也有说明
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操作 就不该在线上服务器发生