MySQL table maintenance


Problem

Sometimes it's a good idea to take care of your tables. What options are there?



Solution

OPTIMIZE TABLE persons

This command is especially useful after you've made a large change to your table. The table as well as the indexes get reorganized and you can free some disk space with it too.

More information here: http://dev.mysql.com/doc/refman/en/optimize-table.html


ANALYZE TABLE persons

This command analyzes the key distribution for the specified table. This helps the query optimizer to do its job better.

More information here: http://dev.mysql.com/doc/refman/en/analyze-table.html


REPAIR TABLE persons

This shouldn't be necessary, but if you have a corrupt table, it might help.

More information here: http://dev.mysql.com/doc/refman/en/repair-table.html

Comments




Please sign-in to post a comment