How to Check Table Size in MariaDB

Galaxy Glossary

How do I check table size in MariaDB?

Check table size in MariaDB by querying INFORMATION_SCHEMA.TABLES or running SHOW TABLE STATUS.

Sign up for the latest in SQL knowledge from the Galaxy Team!
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.

Description

Which SQL query returns a table’s size?

Run a SELECT against information_schema.TABLES. It shows data, index, and total size in bytes, which you can convert to MB or GB on the fly.

Example output columns

table_schema, table_name, data_length, index_length, round((data_length+index_length)/1024/1024,2) AS size_mb.

How do I check one table only?

Filter on table_schema and table_name. This avoids scanning unneeded metadata and speeds up the query on servers with many databases.

Can I list every table size in a database?

Remove the table_name filter. Sort by the calculated column to see the largest tables first.

When should I use SHOW TABLE STATUS?

Use SHOW TABLE STATUS LIKE 'Orders' for a quick, human-readable summary. It’s handy in interactive sessions but harder to script.

Why do index sizes matter?

Indexes increase read performance but consume space. Monitoring index_length helps you spot oversized or unused indexes early.

Best practice: automate regular checks

Schedule the query in a nightly job and store results in an audit table. Trending sizes over time catches growth spikes before disk alerts fire.

Why How to Check Table Size in MariaDB is important

How to Check Table Size in MariaDB Example Usage


-- Find the five largest tables in the shop database
SELECT table_name,
       ROUND((data_length + index_length)/1024/1024,2) AS size_mb
FROM   information_schema.TABLES
WHERE  table_schema = 'shop'
ORDER  BY size_mb DESC
LIMIT 5;

How to Check Table Size in MariaDB Syntax


-- One table, friendly MB output
SELECT table_schema AS db,
       table_name   AS tbl,
       ROUND((data_length + index_length)/1024/1024,2) AS size_mb
FROM   information_schema.TABLES
WHERE  table_schema = 'shop'
  AND  table_name   = 'Orders';

-- All tables in a schema, ordered by size
SELECT table_name,
       ROUND((data_length + index_length)/1024/1024,2) AS size_mb
FROM   information_schema.TABLES
WHERE  table_schema = 'shop'
ORDER  BY size_mb DESC;

-- Quick ad-hoc check
SHOW TABLE STATUS FROM shop LIKE 'Orders';

Common Mistakes

Frequently Asked Questions (FAQs)

Does the query lock my tables?

No. Reading INFORMATION_SCHEMA is non-blocking and safe in production.

Is the size value exact?

Values are approximate; the engine updates them periodically. For byte-level accuracy, run ANALYZE TABLE first.

Can I check partitioned tables?

Yes. Each partition appears as its own row in INFORMATION_SCHEMA.PARTITIONS; aggregate their sizes for a total.

Want to learn about other SQL terms?

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie
BauHealth Logo
Truvideo Logo
Welcome to the Galaxy, Guardian!
Oops! Something went wrong while submitting the form.