mysql truncate slow processing measures

Q5: Are there differences in the implementation of TRUNCATE between different versions?
By comparing 2-Q1 and 3-Q4:
MySQL 8.0's truncate implementation is basically the same as drop, including the main time-consuming locations (both in row_drop_table_for_mysql, os_file_delete_func).

The implementation of truncate and drop in MySQL 5.7 is quite different, and the entire implementation process is almost completely independent code. Truncate uses row_truncate_table_for_mysql,
drop uses row_drop_table_for_mysql; the main time-consuming truncate operations are dict_drop_index_tree and os_file_truncate.


Optimization measures for MySQL 8.0:
If row_drop_table_for_mysql is slow, you can optimize it by setting innodb_adaptive_hash_index = off; if
os_file_delete_func is slow, you can set innodb_flush_method = O_DIRECT or configure the HARD LINK of the table for optimization.
 

Guess you like

Origin blog.csdn.net/royjj/article/details/131400037