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 which uses custom database tables and its impact on the database size.
- To find out if the Action Scheduler database tables, which 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.
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.
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 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.
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 WordPress, including 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.
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
New Customers: Fully Managed Hosting Solutions
- Accessing Your Database in Managed WordPress or WooCommerce Portal
Migrating to Nexcess with managed WordPress and managed WooCommerce hosting
- Going live with your site in Managed WordPress and Managed WooCommerce hosting
- WordPress Cleanup 101: 9 Easy Ways To Clean Up and Optimize Your WordPress Site
- WordPress Database Search: WP DB Search with WP-CLI