MySQL Delete a large table performance problem solution _mysql

Source: Internet
Author: User
On Weibo to discuss MySQL in the Delete large table Engine=innodb (30g+), how to reduce the time of MySQL hang, now do a simple summary:

When the Buffer_pool is very large (30g+), because the delete table, will traverse the entire buffer pool to clean up the data, will lead to MySQL hang live, the solution is:
1, when innodb_file_per_table=0, the above is not a problem, because the use of shared table space, the table occupied by the space will not be deleted, buffer pool in the relevant pages will not be discard.
2, when the innodb_file_per_table=1, and when the buffer_pool larger, traversing the entire buffer pool takes a lot of time (Table_cache will be locked, all DML operations are blocked).

Cognitive misunderstanding :
Changing the InnoDB table to a MyISAM table has no effect, which deletes the old table, creates a new table, and still traverses the entire buffer_pool.

Solution Idea :
1, the use of script form, the bulk of the deletion of records
2, can be slave on the operation of the main standby switch (high cost)
3, Percona 5.1.58 of the above version are supported Innodb_lazy_drop_table (a lot of bugs, use caution)
4, regardless of buffer pool, but can speed up the deletion of data files, the same can reduce the time MySQL hang live. That is: To establish a hard link to the data file (Dependency principle: OS HARD Link When multiple file names point to the same inode, the number of references to this inode n>1, delete any one of the file names just delete a pointer, do not delete the data file. When the number of references to an inode is n=1, deleting the file needs to erase all of the data blocks associated with the file, so it can be time-consuming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.