I wrote a BASH script that will defragment / defrag any fragmented tables. It’s pretty tidy little script in BASH; you can supply usernames and passwords, and even run it against remote MySQL databases.
Here’s an example of it’s output:
root@lit [~]# mysqlDefragmenter
[x] MySQL defragmenter v0.7.4
[x] Written by Phil Dufault ( http://www.dufault.info/ )
[x] Found 76 databases
[x] Checking eximstats ... found 2 fragmented tables.
[x] Optimizing sends ... done
[x] Optimizing smtp ... done
[x] Checking random_forum ... found 9 fragmented tables.
[x] Optimizing datastore ... done
[x] Optimizing forum ... done
[x] Optimizing humanverify ... done
[x] Optimizing posthash ... done
[x] Optimizing postparsed ... done
[x] Optimizing search ... done
[x] Optimizing stopbotsregistry ... done
[x] Optimizing strikes ... done
[x] Optimizing thread ... done
[x] Checking settiphs_blog ... found 1 fragmented table.
[x] Optimizing wp_options ... done
[x] 12 tables were fragmented, and were optimized.
I find this a great script — maybe a feature to add later is a way to prevent it from optimizing really large tables.
Here’s a link to the source:
mysqlDefragmenter
Any other features you’d like to see in it? Comment!
{ 6 comments… read them below or add one }
You did a great job, is a very good script
Thanks!
Thanks for the feedback! Let me know if you see any improvements I can make in the script.
Thanks dude, nice job!
i use this on a ton of my servers.
cheers!
The process of optimizing/fixing fragmented tables has always been kinda painful especially with 100′s of relation tables.
Hundreds of thousands of users thank you…
Great script! How about a parameter to only operate on a specific database (and it’s tables). I need to work on just one table as I am not responsible for all of the tables on this server.
{ 3 trackbacks }