☑ Optimize a MySQL database
Cover Image by MilesAndryPrower on DeviantArt
Cover Image by MilesAndryPrower on DeviantArt

☑ Optimize a MySQL database

If you have deleted a large part of your table or updated many variable length rows, you should consider running the optimize command.

If you want to quickly generate the optimize commands for every table in you database, executing the following MySQL statement:

select concat("optimize table " , TABLE_NAME , ';')

   from INFORMATION_SCHEMA.TABLES

where TABLE_SCHEMA <> 'information_schema' order by 1;
Written by
Stefan Pejcic
Join the discussion

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.