Reorganize table storage and update index statistics for supported engines.
Section: explain and analysis
Optimize a table
sql
sql
OPTIMIZE TABLE orders;Explanation
Best used intentionally; its effect and cost depend on the storage engine and workload.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing explain and analysis
Run EXPLAIN ANALYZE
Execute the query and include actual timing information.
Explain a currently running connection
Obtain the plan for a statement running in another session.