improve optimize script to work as well on weird named tables
This commit is contained in:
parent
fa70de0333
commit
b296d7a710
1 changed files with 2 additions and 2 deletions
|
@ -5,8 +5,8 @@ ENV['HOME'] = '/root'
|
|||
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"
|
||||
system "mysql #{tableitems[0]} -Bse \"OPTIMIZE TABLE #{tableitems[0]}.#{tableitems[1]}\" | grep -q OK"
|
||||
if $?.to_i > 0 then
|
||||
puts "error while optimizing #{tableitems[0]}. #{tableitems[1]}"
|
||||
puts "error while optimizing #{tableitems[0]}.#{tableitems[1]}"
|
||||
end
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue