Mysql tables size is not immediately updated after deletion

I have a database that contains the Logentries of several applications. Now I have written a bash - Script that should remove the oldest day when the size limit is exceeded. I have a loop that deletes day by day until the actual size is less than the limit. But after the delete statements, the table size is not updated properly.

I have used this Sql statement

'SELECT round(((data_length + index_length)), 0) "Size in Bytes" FROM information_schema.TABLES WHERE table_schema = "Log" AND table_name = "Log";'

      

to determine the actual size of the table. How do I get MySql to re-display this size right after the delete command?

+3


source to share


1 answer


Run

 OPTIMIZE TABLE Log

      



After removal. This will update the index statistics (and free up any unused disk space btw).

+6


source







All Articles