Monday, July 16, 2012

MYSQL Table Maintenance

Analyze table
One of the reasons to issue ANALYZE TABLE is that when we have a lot of modification of a table (INSERT or DELETE for example), over time the optimizer might not make the best choices when trying to decide if it should use a specific index or not. By analyzing the table, we help it to make a more educated choice.
To analyze tables, use the command ANALYZE TABLE ‘tablename’;

Check table
Well, check table does what it sounds like, it checks table for errors. It also checks if a table is compatible to current version after an upgrade. To use this, use the commands: CHECK TABLE ‘tablename’;

Optimize table
OPTIMIZE TABLE is used to remove overhead, sort indexes for better access, and generally keep your tables in good order.
To use it, type OPTIMIZE TABLE ‘tablename’;

Repair tables
REPAIR TABLE tries to repair a corrupted or broken table.
Command: REPAIR TABLE ‘tablename’;

No comments:

Post a Comment