MySQL--DROP TABLE与MySQL版本
Posted 笑东风
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL--DROP TABLE与MySQL版本相关的知识,希望对你有一定的参考价值。
========================================================================
DROP TABLE与mysql版本
MySQL在5.5版本中引入自适应hash索引,用于提升经常访问的数据页的性能,在删除表时,需要先通过扫描LRU链表找到该表在自适应hash索引使用的数据页,将这些数据从自适应hash索引中删除。如果为MySQL实例配置较多的物理内存,扫描自适应hash索引的LRU链表可能会导致数据库性能异常甚至数据库Crash。
MySQL 5.7版本的官方文档如下描述:
On a system with a large InnoDB buffer pool and innodb_adaptive_hash_index enabled,TRUNCATE TABLE operations may cause a temporary drop in system performance due to an LRU scan that occurs when removing an InnoDB table‘s adaptive hash index entries.
The problem was addressed for DROP TABLE in MySQL 5.5.23 (Bug #13704145, Bug #64284) but remains a known issue for TRUNCATE TABLE (Bug #68184).
On a system with a large InnoDB buffer pool and innodb_adaptive_hash_index enabled,TRUNCATE TABLE operations may cause a temporary drop in system performance due to an LRU scan that occurs when removing an InnoDB table‘s adaptive hash index entries.
The problem was addressed for DROP TABLE in MySQL 5.5.23 (Bug #13704145, Bug #64284) but remains a known issue for TRUNCATE TABLE (Bug #68184).
对MySQL 5.6之前版本,建议使用TRUNCATE TABLE+DROP TABLE来代替直接DROP TABLE。
对MySQL 5.6及之后版本,建议直接使用DROP TABLE来删除表。
参考链接:
https://dev.mysql.com/doc/refman/5.7/en/truncate-table.html
https://yq.aliyun.com/articles/570032?spm=a2c4e.11155435.0.0.234e998bdGFhGB
以上是关于MySQL--DROP TABLE与MySQL版本的主要内容,如果未能解决你的问题,请参考以下文章
MySQL DROP TABLE操作以及 DROP 大表时的注意事项
MySQL Drop Table Inside Trigger
MySQL drop空表时处于Waiting for table metadata lock状态,解决办法 (出自网络)