Tuesday, December 20, 2016

Solved " MySQL InnoDB not releasing disk space after deleting data rows from table "

Tags




Today, I encountered an issue MySQL InnoDB not releasing disk space even thought most of the data inside are empty.

For your information, innodb will not release the space even though you delete data inside the table. 
People call it a fail design because it hog all the spaces that supposedly be free.

In order to solve this, you have to enabled 'innodb_file_per_table' in mysql.ini 
(Note that if you don't enabled this and just delete the data and run the optimize query (OPTIMIZE TABLE table_name), mysql will reuse it later again hence the space occupy will not change.) 

I wouldn't not go into detail about this because it will take quite long time to explain it. I will just provide you the link to the documentation page. 
InnoDB File-Per-Table Tablespaces

Step 1 : enabled innodb_file_per_table




Step 2 : Restart mysql

Step 3 : Run this query "OPTIMIZE TABLE table_name"





Refresh your database. You should be able to see the table will now use lesser disk space.


If you are facing any problem on this, don't hesitate to message at Obstrum facebook page.

Hope this tutorial will help those in need.

If you want to get in touch with more tutorial, add me on google+ or like and follow our facebook page for more! Obstrum Facebook Page 




EmoticonEmoticon