mysql truncate很慢_mysql truncate 的问题

问题是微信群里一伙计提的

`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操作 就不该在线上服务器发生

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值