WP Server Stats shows database size by table, which tells you where database bloat is coming from. Here is what the main tables contain and how to clean them up safely.
Reading the Database Table Breakdown
WP Server Stats shows each WordPress database table with its size. The standard WordPress tables and what grows in them:
- wp_posts — All posts, pages, custom post types, post revisions, menu items, and widget content. Grows with site age.
- wp_postmeta — Meta data for all posts. ACF fields, WooCommerce product data, SEO metadata, and plugin-specific fields are stored here. Often the largest table on complex sites.
- wp_options — Site settings and autoloaded data. Grows when plugins store data in options without expiry. Autoloaded data here is loaded on every page request.
- wp_usermeta — User meta data. Grows on membership sites with many users.
- wp_comments and wp_commentmeta — Comments and spam. Spam that was not deleted accumulates here.
The wp_options Autoload Problem
wp_options is the most common performance-related database problem. Many plugins store data in wp_options with autoload=yes, meaning the data loads on every single page request regardless of whether it is needed. A bloated wp_options table with many large autoloaded rows significantly increases memory usage and query time.
To check autoloaded data size, run this SQL query in phpMyAdmin:
SELECT SUM(LENGTH(option_value)) as total_bytes
FROM wp_options
WHERE autoload = 'yes';
If this returns more than 1MB, you have an autoload problem worth investigating.
Cleaning Post Revisions
WordPress saves a revision every time you save a post. On actively maintained sites, this creates many revisions per post. Limit future revisions by adding to wp-config.php:
define( 'WP_POST_REVISIONS', 5 ); // Keep last 5 revisions only
To delete existing revisions, use WP-Optimize or run SQL directly in phpMyAdmin:
DELETE FROM wp_posts WHERE post_type = 'revision';
DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT ID FROM wp_posts);
Always back up before running SQL statements directly.
Cleaning Expired Transients
Transients are temporary data caches stored in wp_options. They should expire and be deleted automatically, but failed deletions cause accumulation. Clean expired transients using WP-Optimize or this SQL:
DELETE FROM wp_options
WHERE option_name LIKE '_transient_%'
AND option_name NOT LIKE '_transient_timeout_%'
AND option_name IN (
SELECT CONCAT('_transient_', SUBSTRING(option_name, 20))
FROM wp_options
WHERE option_name LIKE '_transient_timeout_%'
AND option_value < UNIX_TIMESTAMP()
);
Deleting Spam Comments
Akismet and other spam filters mark comments as spam but do not delete them. Go to Comments in WordPress admin, filter by Spam, and bulk delete all spam comments. Do this regularly -- spam comment accumulation can add significant database size on active sites.
After Cleanup: Run Database Optimization
After deleting large amounts of data, run a database optimisation to reclaim the freed space. WP-Optimize includes this feature. Or use phpMyAdmin to select all tables and run Optimize Table, which defragments the table files and reduces their size on disk.
For database performance analysis, custom indexing for large post archives, and query optimisation on high-traffic WordPress sites, a WordPress developer can identify and resolve database performance issues.