Finding MySQL Table Disk Usage Via SQL

A little snippet that’s a deep-geek note-to-self. Darren found this from modifying information on this site and I figured I wanted to keep it around as it looks potentially handy to have. Also once google indexes things I’ll be able to find it easily again!

table_schema, count(*) TABLES,
total_size,round(sum(index_length)/sum(data_length),2) idxfrac
information_schema.TABLES group by table_schema;

One Comment on “Finding MySQL Table Disk Usage Via SQL”

  1. Handy enough, but data size != disk space used, especially if your tables are InnoDB. With MyISAM tables, deleted rows aren’t freed up until you do an optimize table. With InnoDB, you’ve got shared table space, and the disk space used can bear very little resemblance to the actual size of your data.
    Just thought I’d mention it 🙂