Skip to content

Instantly share code, notes, and snippets.

@jphenow
Created September 9, 2013 14:33
Show Gist options
  • Save jphenow/6496435 to your computer and use it in GitHub Desktop.
Save jphenow/6496435 to your computer and use it in GitHub Desktop.
For collecting size of your DB in Megabytes
User.find_by_sql(
%q{
SELECT table_schema 'table', sum( data_length + index_length ) / 1024 / 1024 'size'
FROM information_schema.TABLES GROUP BY table_schema;
}
).each { |u| puts "#{u.table}: #{u.size} MB" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment