By using a simple WP-CLI command, you can easily find the size of your WordPress database, as well as the sizes of the individual tables inside it. In this article, we'll show you how to check your database and table sizes with WP-CLI.
Getting the Total Database Size
To get your total database size, simply run the following WP-CLI command from within the root directory of your WordPress site:
wp db size
Getting Individual Table Sizes
If you're trying to identify large tables within your WordPress database, you'll probably want to display the sizes for each of the tables. To output sizes by table, simply append the command with the --tables option like this:
wp db size --tables
Changing the Size Format
By default, all database size commands will output the sizes in bytes. To better read your sizes, you might want to change the output to kilobytes, megabytes, or even gigabytes. Simply use the --size_format option like this:
wp db size --size_format=kb
Supported size formats are the following:
- b (default)
- kb
- mb
- gb
- tb