Problem DescriptionAfter deleting data using the delete statement in MySQL, the available disk space in the monitoring view did not increase, the disk usage did not decrease, and so on. SolutionThe reason why delete does not release space is due to MySQL's own mechanism. You need to rebuild the table to release disk space. You can refer to the following operations:
There are two issues to note: Both commands will rebuild the table. Try not to perform the operation when the disk space is tight (>90%). Expand the disk first and then shrink it after the operation. Problem AnalysisIn the MySQL mechanism, the rows deleted by delete are only marked as deleted. If there are many rows deleted and all the rows of the entire data page (innodb_page) will be deleted, the data page will only be marked as deleted. It will not be physically deleted, but will be occupied all the time, waiting to be reused. For example: It can be seen that data_length does not change before and after delete, but data_free increases a lot. This means that although the data has been deleted, it has not been released and is still occupied by the test1 table, but is displayed as being in a free state. When new data is written in the future, it can be reused directly without applying for new disk space. At this time, use You can see that data_length and data_free have both become empty tables, with only one innodb_page (default 16k). PS: data_free itself can also be used to evaluate the space fragmentation of a table. When this number is very high, you can consider using the same method to rebuild the table and reclaim some disk space. The above are the details of why the disk space is not released after MySQL Delete deletes data. For more information about why the disk space is not released after MySQL deletes data, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: ElementUI implements cascading selector
>>: Grid systems in web design
Project Documentation Directory Div+CSS Naming Sta...
Preface The best method may not be the one you ca...
By default, PHP on CentOS 7 runs as apache or nob...
3 ways to implement tab switching in Vue 1. v-sho...
Preface I wrote a few examples using vue3, and I ...
1. Import the basic style of external CSS files U...
Today, when learning PHP, of course, you have to ...
This article shares the specific code of JavaScri...
Table of contents Browser kernel JavaScript Engin...
This article describes how to build a phalcon env...
This article example shares the specific code of ...
The pagination component is a common component in...
Preface I recently sorted out my previous notes o...
First, the server environment information: Reason...
Table of contents Preface Arrow Functions Master ...