Created
March 16, 2011 05:03
-
-
Save ajsharp/872043 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :db do | |
desc "Display the aggregate size of all database indexes" | |
task :index_size => :environment do | |
results = ActiveRecord::Base.connection.select_all("show table status;") | |
puts "Total Database Index Size: #{results.sum { |row| row['Index_length'].to_i / 1048576 }} MB" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment