MySQL database, delete record does not free storage space

Source: Internet
Author: User

In the MySQL database, when we delete a database record using a statement such as delete from table where the record is deleted, the record is not found with SELECT, but the storage footprint of the table is not reduced because the use of such a statement is performed by a tombstone, The database simply deletes the tag and does not actually erase the data from the physical disk.

Therefore, in order to completely delete, you need to use TRUNCATE TABLE or delete without the where condition, so that all the data can be physically deleted. But the actual often can not execute such a statement, the table all the data is emptied, then how to achieve only part of the data physical deletion?

1. Execute the delete from table where the statement

2. Tablespace defragmentation, OPTIMIZE table, when using this statement, the tables are locked, so always note that it is recommended to execute the statement once a week or every month before using it.

MySQL database, delete record does not free storage space

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.