Mysql Delete the database size does not change after the record is deleted _mysql

Source: Internet
Author: User
Tags mysql delete

This problem occurs when the delete is followed by the condition.

Delete from table_name WHERE condition

When you delete data, the amount of space that the datasheet occupies does not change.

When you do not follow the conditions directly delete.

Delete from table_name

The data is cleared, and the space of the datasheet becomes 0.

If a large portion of the table data has been deleted, or there are many changes and variable-length table rows (varchar tables, VARBINARY, blobs, or text columns) have been changed because of the fragments left in the data file after the delete operation. Delete simply deletes the data identifier and does not defragment the data file, and when new data is inserted, the record space that is placed to remove the identity is reused again, and you can use the Optimize table to reclaim unused space and defragment the data file.

OPTIMIZE table works only for MyISAM, BDB, and InnoDB tables.

OPTIMIZE table name;

For the MyISAM engine, using optimize table also has the following features:

If the table has deleted or split rows, repair the table. [Repair Table]
If The index pages are not sorted, sort them. [Index not sorted, sort]
If The table ' s statistics are not up to date (and the repair could is accomplished by sorting the index), update them. [Update it if the table's statistics are not up to date]

After the bulk deletion of the Myiam datasheet, found that the space is not recycled, to reclaim space by optimize table

The above mentioned is a small set of MySQL to introduce the delete record database size unchanged after the relevant knowledge, I hope to help!

Related Article

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.