Database size

from the Artful Common Queries page


For schema 'db' ...
select 
  concat(round(sum(table_rows)/1000000,2),'m') rows,
  concat(round(sum(data_length)/(1024*1024*1024),2),'g') data,
  concat(round(sum(index_length)/(1024*1024*1024),2),'g') idx,
  concat(round(sum(data_length+index_length)/(1024*1024*1024),2),'g') total_size,
  round(sum(index_length)/sum(data_length),2) idxfrac
from information_schema.tables
where table_schema='db';

Last updated 1 May 2024