↑ ↓ select, Enter open, Esc close

Find the 20 largest tables on the server

root@server
mysql -e 'SELECT table_schema, table_name, ROUND((data_length + index_length) / 1024 / 1024, 1) AS mb, table_rows FROM information_schema.tables ORDER BY data_length + index_length DESC LIMIT 20;'

Lists the 20 largest tables of all databases with database name, table name, size in MB and estimated row count. Typical candidates are log and statistics tables from plugins, sessions or a bloated wp_options. Add WHERE table_schema = 'wp_example' before ORDER BY to limit the query to one database.

Note: For InnoDB, table_rows is only an approximation.

Also searched as

  • largest mysql tables
  • which table is so big
  • find bloated database table

Related one-liners

All in MySQL and MariaDB

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.