Table optimisation can reclaim or reorganise storage after substantial data changes, depending on the storage engine. It is not a universal cure for slow websites, and unnecessary rebuilds can consume disk space and interfere with busy applications.
IN THIS ARTICLE
Information to have ready
Back up the database and identify the table’s engine, size and available disk space. Investigate slow queries and indexes first if performance is the main problem. Schedule maintenance when the table can tolerate the operation’s locking or resource use.
01 Assess and run the appropriate table operation
- Select the database in phpMyAdmin and inspect the table’s size, engine and relevant maintenance information.
- Choose only the table that has a justified need for maintenance. Avoid blindly selecting every table on a production shop.
- Use the supported Optimize table action and wait for the result. Read the full message rather than treating every informational note as a failure.
- For InnoDB, the server may perform a table rebuild or equivalent supported operation. Ensure sufficient spare space and do not interrupt a long operation without administrator guidance.
- After completion, inspect the table status and test the application. Compare a meaningful baseline, such as a slow query or storage measurement, with the result.
02 Example: inspect a table before deciding to optimise it
In the selected database's phpMyAdmin SQL tab, replace example_orders with the actual table name and inspect its status. This reads metadata and does not rebuild the table.
SHOW TABLE STATUS WHERE Name = 'example_orders';
Review Engine, Data_length, Index_length and Data_free in the context of that server's storage configuration. InnoDB row totals reported through table statistics can be estimates, and a displayed free-space figure does not guarantee that running OPTIMIZE will return that amount to the operating system.
If the real complaint is a slow checkout query, collect its execution plan and workload evidence first. If a justified rebuild is needed, arrange sufficient temporary space and a maintenance window using the server's supported procedure. Compare the same measurement afterwards and verify the application, rather than optimising every table on a schedule without evidence.
Confirm the expected result
The table should remain accessible and the intended maintenance outcome should be visible. Reduced file size is not guaranteed for every engine or storage configuration.
What if table optimisation fails or the database remains slow?
If the operation fails, preserve the error and ask support about engine behaviour, privileges and capacity. Do not repeatedly retry while disk space is critically low. For ongoing slowness, examine query plans, missing indexes, application workload and resource limits instead of scheduling constant optimisation.