diff options
author | mh <mh@immerda.ch> | 2009-02-21 17:22:47 +0000 |
---|---|---|
committer | mh <mh@immerda.ch> | 2009-02-21 17:22:47 +0000 |
commit | 288a33be75de3d6e75d6039bd92dcfda46fda190 (patch) | |
tree | ef36965c38daa0b7cd7e89fc5aea6e1130572416 /files | |
parent | 2dc631bd2a441644090ae9075135db8e977ff03e (diff) |
merged with puzzle
Diffstat (limited to 'files')
-rw-r--r-- | files/optimize/optimize_tables.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/files/optimize/optimize_tables.rb b/files/optimize/optimize_tables.rb new file mode 100644 index 0000000..5bd2a1f --- /dev/null +++ b/files/optimize/optimize_tables.rb @@ -0,0 +1,10 @@ +#!/usr/bin/env ruby + +tables = %x{mysql -Bse "SELECT TABLE_SCHEMA,TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA NOT IN ('information_schema','mysql') AND Data_free > 0 AND ENGINE IN ('MyISAM','InnoDB','ARCHIVE')"} +tables.each { |table| + tableitems = table.chomp.split(/\t/) + system "mysql #{tableitems[0]} -Bse \"OPTIMIZE TABLE #{tableitems[1]}\" | grep -q OK" + if $?.to_I > 0 then + puts "error while optimizing #{tableitems[0]}. #{tableitems[1]}" + end +} |