Nexcess Logo

WordPress Database Size: Find WP DB Size with WP-CLI

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
January 25, 2022

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!

WordPress Database Size: How to Find Out the Database Size Using WP-CLI

You can typically find the size of the site’s database using a database tool like phpMyAdmin, but using this method can take longer, and you have to perform the check in the user interface, which can be cumbersome.

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

  • To find out about any of the email logging activity and its impact on the database size.
  • To find out about any of the active plugin logging which uses custom database tables and its impact on the database size. 
  • To find out if the Action Scheduler database tableswhich are used by a number of different plugins, including WooCommerce, are getting large. 

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:

cd public_html

WP-CLI DB Size Command

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

wp db size

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:

wp db size --tables

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

wp db size –all-tables-with-prefix

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

wp db size –all-tables

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:

wp db size --tables --human-readable

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:

* b (bytes)

* kb (kilobytes)

* mb (megabytes)

* gb (gigabytes)

* tb (terabytes)

* B (ISO Byte setting, with no conversion)

* KB (ISO Kilobyte setting, with 1 KB = 1,000 B)

* KiB (ISO Kibibyte setting, with 1 KiB = 1,024 B)

* MB (ISO Megabyte setting, with 1 MB = 1,000 KB)

* MiB (ISO Mebibyte setting, with 1 MiB = 1,024 KiB)

* GB (ISO Gigabyte setting, with 1 GB = 1,000 MB)

* GiB (ISO Gibibyte setting, with 1 GiB = 1,024 MiB)

* TB (ISO Terabyte setting, with 1 TB = 1,000 GB)

* TiB (ISO Tebibyte setting, with 1 TiB = 1,024 GiB)

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

– b
– kb
– mb
– gb
– tb
– B
– KB
– KiB
– MB
– MiB
– GB
– GiB
– TB
– TiB

Size Format in MB

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

wp db size --size_format=mb

Size Format in GB

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

wp db size --size_format=gb

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 db size --network

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.

Useful WordPress Links for Developers & Admins

Next Steps?

Read more about the Fully Managed WordPress Hosting and its benefits for your business.

Build Better Websites with Fully Managed WordPress Hosting 

It’s hosting optimized for WordPress. That means a faster, more secure and scalable website. Smart monitoring tools are built-in to help you keep it that way. 

It’s why WordPress Users Trust Nexcess Hosting.

We also have a variety of Nexcess support articles about WordPressincluding how to get your site going with a number of different configuration options. These resources include a great article on setting this up for Migrating to Nexcess with managed WordPress and managed WooCommerce hosting

24-Hour Assistance

If you need any assistance with the above-mentioned, don't hesitate to reach out. For 24-hour assistance any day of the year, Nexcess customers can contact our support team by email or through your Client Portal.

Useful YouTube > Nexcess Channel Links

Resources for More Information

Need more help? The Applications, WooCommerceand WordPress sections within the Nexcess Knowledge Base are important resources for those seeking additional knowledge. Or, check out our related articles below.

New Customers: Fully Managed Hosting Solutions

Not a Nexcess customer yet? Check out our fully managed hosting solutions. The option to chat with an expert is also available.

Related Articles

Luke Cavanagh
Luke Cavanagh

Luke Cavanagh, Strategic Support & Accelerant at Liquid Web, brings a decade of experience working with WordPress and WooCommerce to our product team. His GitHub page offers a glimpse into his multiple areas of subject matter expertise.

"Ninja stuff with WordPress and WooCommerce," is an apropos way to describe Luke's savviness with these platforms — and his way of influencing our organization for improving to them.

Coming out of the University of Brighton with a Business and Technology Education Council (BTEC) Higher National Diploma (HND) in 2D & 3D Design, Luke's credentials prepared him well for his current role that blends both web development and design. His HND credential leveraged his foundational learning at West Kent College, where is received a National Diploma (ND) in Graphic Design.

In his personal life, Luke is a devoted husband and teen wrangler. He considers himself a Synthwave enthusiast, Jerry Goldsmith fan, and Doctor Who aficionado. He is happy to introduce his friends and teammates to essential vocabulary for life found only in British English, such as "gubbins" and similar terms.

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.