From 288a33be75de3d6e75d6039bd92dcfda46fda190 Mon Sep 17 00:00:00 2001 From: mh Date: Sat, 21 Feb 2009 17:22:47 +0000 Subject: merged with puzzle --- files/optimize/optimize_tables.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 files/optimize/optimize_tables.rb (limited to 'files') 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 +} -- cgit v1.2.3