Automatically optimize all tables in a MySQL database
Posted by webdigity on June 9, 2006
Use this script preferably with a cronjob to automatically optimize all the tables in your mysql databases. Under root privilleges the script will search for all the databases in your server and will optimize them all. Hope you will like it as it took me more than 3 hours to write it
Optimize all databases/tables in MySQL
For more tutorials you can refer here
Niche said
Thanks for sharing that.
Very usefull script
webdigity said
No worries
I will try to post more usefull stuff later.
stelmi said
Why are you don’t use mysqlcheck application? I think it will be easier to run this program from crontab with appropraite option. MOre detail are here:
http://dev.mysql.com/doc/refman/5.0/en/mysqlcheck.html
webdigity said
mysqlcheck is a little slow, but the most important is that it can break tables that have unicode charsets.
Anyway this script optimizes only tables that want optimization, while the mysqlcheck optimizes everything.
sup said
Are you kidding me with the code coloring?
webdigity said
If you can’t read it, just copy/paste it somewhere my friend
Brian S said
Works beautifully. Implemented on all of my servers. Thanks.
drmike said
Thanks.
I’ve found mention of how one should run a FLUSH TABLES after optimizing one’s db.
Yes/No?
Thanks,
-drmike
webdigity said
Why to flush tables after the optimizing process?
Dr. Mikes Blog » Optimize MySQL said
[...] code for the most part comes from here with some modifications made by myself to allow for the WPMu system. Instructions are included [...]
Optimize MySQL « Dr. Mike’s Blog said
[...] code for the most part comes from here with some modifications made by myself to allow for the WPMu system. Instructions are included [...]
GreyDuck said
This is exactly the piece of kit I was looking for. Thank you!
machiner said
Schweet script. Fast. Thank you for writing it.
–machiner
Web 2.0 Announcer said
Automatically optimize all tables in a MySQL database
[...]Use this script preferably with a cronjob to automatically optimize all the tables in your mysql databases. Under root privilleges the script will search for all the databases in your server and will optimize them all.[...]
tending the garden » links for 2007-06-14 said
[...] Automatically optimize all tables in a MySQL database « Webdigity – Thoughts on SEO and Web develop… optimize – a script for running it automatically (tags: howto mysql optimization php script wordpress) [...]
Tracy said
I have implemented this script on one of my blogs, thanks very much