MySQL Delete the database size unchanged after deleting the record

Source: Internet
Author: User


This problem occurs when the delete is followed by a condition

Delete from table_name WHERE condition

When you delete data, the size of the data table takes up no change.

When you do not delete the condition directly.

Delete from table_name

Data is cleared and the data table's space becomes 0


If a large portion of the table data has been deleted, or there are many changes and changes to the long table row (varchar table, VARBINARY, blob, or text column), the deletion is caused by a fragment left in the data file. Delete simply deletes the data identity bits, does not defragment the data file, and once the new data is inserted, it uses the record space that is set to delete the identity again, you can use optimize table to reclaim unused space, and defragment the data file.


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


OPTIMIZE table name;



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

If the table has deleted or split rows, repair the table. [Repair Table]

If The index pages is not sorted, sort them. [Index not sorted, sorted]

If The table ' s statistics is not up to date (and the repair could is accomplished by sorting the index), update them. [If the statistics for the table are not up to date, update it]

After bulk deletion of the Myiam data table, it is found that the space is not recycled and the space is reclaimed by optimize table.


This article is from "I am a small fish" blog, please be sure to keep this source http://kevinfish.blog.51cto.com/1183772/1793009

MySQL Delete the database size unchanged after deleting the record

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.