How much table overhead is too much?
Question
I just saw in phpMyAdmin that one of our MySQL tables is 14MB in size, but has 10MB overhead. I'm guessing this is a lot!
How much is too much? Should I run OPTIMIZE TABLE
regularly?
Solution
"Overhead" is not yet reclaimed space formerly occupied by now deleted records. If you're doing a lot of inserts / deletes, it's pretty much always going to be there. You can run OPTIMIZE TABLE
, but I wouldn't bother - especially on large tables (14M is not large, though) where it can take a lot of time.
OTHER TIPS
To tidy up data table one can just use:
ALTER TABLE table_name_here ORDER BY primary_key_here;
which could run faster than OPTIMIZE TABLE
.
This will de-fragment the data file. After extensive changes to a table, this may also improve performance of statements that use the table, sometimes significantly.