Guides

Quickly check MySQL storage usage with simple queries.
Database Guides

How to Check MySQL Database and Table Size

Find large databases and tables using SQL in seconds.

Before you start

You need access to MySQL.
You must have permission to read information_schema.
Queries work on MySQL and MariaDB.

Check database size

SQL
SELECT count(*) NUM_OF_TABLE,
       table_schema,
       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
GROUP BY table_schema
ORDER BY sum(data_length+index_length) DESC
LIMIT 10;
What it shows

DATA = data size, idx = index size, total_size = total usage.

Check table size

SQL
SELECT 
    table_name,
    table_rows,
    round(data_length/(1024*1024),2) AS DATA_SIZE_MB,
    round(index_length/(1024*1024),2) AS INDEX_SIZE_MB
FROM information_schema.TABLES
WHERE table_schema = 'your_database_name'
ORDER BY data_length DESC;
Important

Replace 'your_database_name' with your actual database name.

Common issues

table_rows is not exact

In InnoDB, row count is approximate.

Permission denied

You need access to information_schema.

Database name error

Make sure you replace the schema name correctly.

About this guide

This guide shows how to check MySQL database size and table size using information_schema. It is useful when you want to identify large databases or tables.

How to follow this guide

  1. Run a query to check database size.
  2. Run a query to check table size.
  3. Analyze which database or table is consuming the most space.

Why use this method?

Knowing database and table size helps you manage storage, optimize performance, and identify unnecessary data.

Frequently Asked Questions

Is table_rows accurate?

For InnoDB tables, table_rows is an estimate, not exact.

What is information_schema?

It is a system database that stores metadata about all tables and schemas.

Why is index size large?

Large indexes may indicate heavy indexing or inefficient schema design.

Do I need special permissions?

You need permission to read information_schema tables.