dufault.info

Ramblings of a phone weenie, Linux sysadmin, and other things geeky

08 2008

A Script to Optimize Fragmented Tables in MySQL

I wrote a BASH script that will run “optimize table” on any table fragmented. it’s pretty tidy, and you can supply usernames and passwords, and even run it against remote MySQL databases.

Here’s an example of it’s output:
root@lit [~]# mysqlFragFinder
MySQL fragmentation finder (and fixer) v0.7.2, written by Phil Dufault ( http://www.dufault.info/ )
Found 59 databases
Checking someforum_forum … found 1 fragmented table.
Optimizing log_online … done
Checking dufault_blog … found 2 fragmented tables.
Optimizing wp_comments … done
Optimizing wp_options … done
3 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:
mysqlFragFinder

Any other features you’d like to see in it?   Comment!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Mixx
  • StumbleUpon
  • Technorati

1 Comment

(Required)
(Required, will not be published)

This site uses KeywordLuv. Enter YourName@YourKeywords in the Name field to take advantage.

« MySQL Tuner Billix »