Table of contents
Get the industry’s fastest hosting for WordPress◦ 99.999% uptime
◦ Comprehensive security
◦ 24/7 support

WordPress GuideWP-CLI → Database Size

WordPress database size: Find WP DB size with WP-CLI

Find your database size quickly using the WordPress Command Line Interface (WP-CLI)! The WP database size is at your fingertips, and here’s how to find it!

Get fast, reliable hosting for WordPress

Power your site with the industry’s fastest, most optimized WordPress hosting

WordPress database size: How to find Out the database size using WP-CLI

Reasons why you would need to find out the size of your database include:

Other plugins which can add to the site’s database bloat would be activity logging plugins such as Stream or Simple History. If your database size is much larger than you would expect based on the number of posts, pages, and form submissions on your site, or if you are running a plugin such as WooCommerce, then it would be based on the number of customers, products, and orders. 

Checking your site database size will also keep your site performing well since any odd database size increases can negatively impact performance. An example would be if your database size jumped from say 600 MB to 25 GB in size, then it would show that a process from a plugin was causing a massive amount of bloat. And then, to find out which plugin, and by that reckoning, which database table had the increase in size. Also, checking if the site’s options database table jumped in size or not, since that could hint at a massive influx in transients being stored in it.

There is a much easier command-based method to find the size of the site’s database by using WP-CLIThe WP-CLI command will use the database name that is defined in the site’s wp-config.php file.

How to Use WP-CLI

To use WP-CLI on your site, you will need to find and then use the SSH credentials from the site’s portal. To use WP-CLI, you will need to use a command-line application that will depend on if you are using a Mac or PC. If using a Mac, you can use Terminal. If you are using a PC, then the recommendation would be to use Putty.

Using WP-CLI

WP-CLI can only be used from the valid WordPress installation, which would be from:

WP-CLI DB size command

The WP-CLI command to find the size of the database is:

List the size of tables in the Database

To find out the size of the different tables within the database, use this WP-CLI command:

To list all of the tables that use the prefix defined in the wp-config.php file, then use this WP-CLI command:

To list all of the tables that are used in the site’s database, then use this WP-CLI command:

Outputting in a human readable format

If you want to output the size in a more human-readable format, then use the following WP-CLI command:

Size formats supported

There is also a size format flag that supports a number of different options such as bytes, kilobytes, megabytes, gigabytes, and terabytes. The available size formats include:

A complete list of all of the size format options that can be used are as follows:

WP-CLI DB size command

The WP-CLI command to find the size of the database is:

Size format in MB

To get the size of the database in the MB format, use this WP-CLI command:

Size format in GB

To get the size of the database in the GB format, use this WP-CLI command:

Size of the network tables

If your site is multisite, then you can find out the size of all database tables within the network using this WP-CLI command with the network flag set on it:

WP-CLI ease of use

Using any of the WP-CLI commands to get the size of the site’s database will make it much easier to find out the size of the site’s database. The WP-CLI database command has several flags that will help you find out the specific information you need.

Additional resources

What is WordPress? →

A complete beginner’s guide—from use cases, to basics, to how to get started

What is WP-CLI →

WP-CLI allows you to manage your users from the command line. This can come in handy when modifying privileges and changing roles quickly.

How to integrate WordPress and Slack →

If your org uses Slack and WordPress, there are several ways you can tie them together.

Luke Cavanagh

Luke Cavanagh, Strategic Support & Accelerant at Liquid Web, is one of the company’s most seasoned subject matter experts, focusing on web hosting, digital marketing, and ecommerce. He is dedicated to educating readers on the latest trends and advancements in technology and digital infrastructure.