Using hard links to delete MySQL large files in seconds _ MySQL

Source: Internet
Author: User
Using hard links to delete MySQL large files in seconds bitsCN.com

Using hard links to delete large MySQL files in seconds

Principle:

Hard link basics

When multiple files point to the same inode, inode connections N> 1, deleting any file is extremely fast.

This is because only the pointer to inode is deleted.

When N = 1, it is different. at this time, all data blocks related to the deleted file are slow.

Test:

[Plain] root @ # ln stock. ibd stock. id. hdlk root @ # ls stock. *-l-rw -- 1 mysql 9196 Apr 14 stock. frm-rw-r-2 mysql 19096666112 Apr 15 stock. ibd-rw-r-2 mysql 19096666112 Apr 15 stock. id. hdlk, you will find stock. the INODES attribute of ibd is changed to 2;

Next we will continue to delete the table.

root@127.0.0.1 : test 21:44:37> show table status like ‘stock’ /G  *************************** 1. row ***************************  Name: stock  Engine: InnoDB  Version: 10  Row_format: Compact  Rows: 49916863  Avg_row_length: 356  Data_length: 17799577600  Max_data_length: 0  Index_length: 1025507328  Data_free: 4194304  Auto_increment: NULL  Create_time: 2011-05-18 14:55:08  Update_time: NULL  Check_time: NULL  Collation: utf8_general_ci  Checksum: NULL  Create_options:  Comment:  1 row in set (0.23 sec)  root@127.0.0.1 : test 21:39:34> drop table stock ;  Query OK, 0 rows affected (0.99 sec)  

The deletion is completed in less than one second, that is, the drop table does not need to be HANG for so long.

However, the table is deleted and the data file is still there. Therefore, you need to delete the data file.

root # ll  total 19096666112  -rw-r–r– 2 mysql mysql 19096666112 Apr 15 09:55 stock.id.hdlk  root # rm stock.id.hdlk  

The last step to delete the original large file can also choose rsync to delete, faster than rm: rsync seconds to delete the large file http://www.bitsCN.com/ OS /201304/203155.html

BitsCN.com

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.