Skip to content

Instantly share code, notes, and snippets.

@ajsharp
Created March 16, 2011 05:03
Show Gist options
  • Save ajsharp/872043 to your computer and use it in GitHub Desktop.
Save ajsharp/872043 to your computer and use it in GitHub Desktop.
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