Quantcast
Channel: What can cause TRUNCATE TABLE to take a really long time? - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 3

Answer by Ramisha Farrukh for What can cause TRUNCATE TABLE to take a really long time?

$
0
0

First of all you should use latest version of MySQL or MariaDB as in these version this bug has been fixed.

This bug can come up when you DROP or TRUNCATE a table and you have a large buffer pool, there can be server lock-up or stall of multiple seconds which makes your table unresponsive.

Depending on the server’s CPU and memory bandwidth, the stall can be as much as 1 second per 32GB of RAM. If your buffer pool is 1TB that can mean your entire database locks up for as long as 30 seconds. There is different workaround for this bug depending on your circumstances as you have not shared complete detail so, I am suggesting some. You can also find more details MySQL troubleshooting article.

One possible solution can be delete all rows before dropping a table, this will not cause a memory stall because there will be no data in memory.

Another solution can be use of non-InnoDB storage engine for temporary tables. You can specify ENGINE=MyISAM in your CREATE TABLE statement. If you have a large code base and don’t explicitly specify the storage engine, you can change the default storage engine to MyISAM by adjusting the following configuration option:

default_tmp_storage_engine = MyISAM

The good news is that the fix itself has been implemented MariaDB 10.2.19, MySQL 8.0.23 and later.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images