Havenswift Hosting Ltd
All guides

Repairing and optimising database tables

Two different operations that are often confused.

Repair

Fixes a table reporting itself as corrupt – usually after an interrupted write. The symptom is an error naming a specific table and telling you to repair it. In phpMyAdmin, select the table, then choose Repair table from the operations dropdown.

If tables corrupt repeatedly, that is not something to keep repairing. Tell us, because the cause is usually something else – a process being killed for exceeding limits, or a disk problem.

Optimise

Reclaims space left behind by deleted rows. Deleting a hundred thousand rows does not necessarily shrink the file; optimising rebuilds it. Worth doing after a large cleanup, and largely pointless as a routine.

When it actually helps

What optimising will not fix

It will not make a slow query fast. Slowness is nearly always a missing index or a query doing too much work, not fragmentation. Optimising a table and finding no difference is the normal outcome – look at the query instead.

Take a backup first

Both operations lock the table while they run, so do them at a quiet time, and export the database first. On a busy shop, a locked table means errors for customers.

Other guides

Still stuck? Sign in and raise a ticket, and somebody will answer it.

Sign in