WordPress & WooCommerce Database Guide
How to Reduce WordPress Database Size and Speed Up Your Site
Learn how to reduce WordPress database size safely: find the tables that bloat it, clean revisions, transients, autoloaded options and plugin leftovers, and optimize WooCommerce data without losing orders.
Every page view on a WordPress site runs dozens of database queries. When the database is full of junk, every one of those queries gets slower. The admin dashboard drags, WooCommerce checkout lags, backups take forever and migrations fail.
I am Md Juwel Rana, a WordPress developer at Web Relife. I clean and optimize WordPress and WooCommerce databases for clients in the US, UK and Europe. This is the process I use to reduce WordPress database size without breaking anything.
Why Does a WordPress Database Get So Big?
- Post revisions. WordPress saves a full copy of a post every time you click Update. A post edited 80 times has 80 copies.
- Expired transients. Temporary cache data that plugins store in
wp_optionsand often never delete. - Autoloaded options. Settings loaded on every single page request. Old plugins leave large autoloaded rows behind.
- Plugin leftovers. Deleting a plugin rarely deletes its tables and settings.
- Logs and sessions. Security, email, redirect and WooCommerce Action Scheduler logs grow forever.
- Spam and trashed content. Spam comments, trashed posts and orphaned metadata.
How to Check Your WordPress Database Size
Method 1: Site Health
Go to Tools → Site Health → Info → Directories and Sizes and look at Database size.
Method 2: phpMyAdmin
Open phpMyAdmin from your hosting panel, select your database and sort the tables by Size. The top five tables usually explain most of the bloat.
Method 3: SQL query
Run this in phpMyAdmin's SQL tab to list your largest tables (replace your_db_name):
The Tables That Bloat the Most
| Table | What fills it | Cleanup risk |
|---|---|---|
| wp_options | Expired transients, heavy autoloaded settings, plugin leftovers | Medium |
| wp_posts | Revisions, auto-drafts, trashed posts | Low |
| wp_postmeta | Orphaned meta, page builder data, old product meta | Medium |
| wp_comments / commentmeta | Spam and trashed comments | Low |
| wp_actionscheduler_* | Completed and failed WooCommerce background jobs | Low |
| wp_wc_sessions | Expired WooCommerce customer sessions | Low |
| Plugin log tables | Security, email, redirection and 404 logs | Low |
| Unknown custom tables | Tables from plugins you may still use | High |
How to Reduce WordPress Database Size: 8 Safe Steps
1. Delete post revisions
Remove old revisions, then limit future ones with define('WP_POST_REVISIONS', 5); in wp-config.php (see the official wp-config.php handbook).
2. Clear expired transients
Delete expired _transient_ rows from wp_options. They rebuild automatically when needed.
3. Fix heavy autoloaded options
Find the largest autoloaded rows and turn off autoload for ones from removed plugins. See my guide to autoloaded options.
4. Remove spam & trash
Empty spam and trashed comments, trashed posts and old auto-drafts.
5. Delete orphaned metadata
Remove postmeta and commentmeta rows whose parent post or comment no longer exists.
6. Drop leftover plugin tables
Only for plugins you have fully removed. Check the table prefix and owner before dropping anything.
7. Purge old logs
Clear security, email, 404 and Action Scheduler logs, then set the plugins to keep only 30 days.
8. Optimize the tables
Run OPTIMIZE TABLE (or phpMyAdmin → Optimize table) to reclaim space after deleting rows.
SQL Queries to Clean the WordPress Database (Developers)
Use these only after a full backup. Replace wp_ with your own table prefix.
Find the heaviest autoloaded options:
Prefer WP-CLI? wp transient delete --expired and wp db optimize do the same job from the command line.
WooCommerce Database Cleanup
WooCommerce stores add their own bloat on top of WordPress. Clean these carefully, because order data must never be lost:
- Action Scheduler: Go to WooCommerce → Status → Scheduled Actions and remove old complete, failed and canceled actions. Their logs live in
wp_actionscheduler_logs. - Customer sessions: In WooCommerce → Status → Tools, use Clear customer sessions to empty expired sessions.
- WooCommerce transients: Use Clear transients and Clear expired transients in the same Tools screen.
- HPOS: After moving to High-Performance Order Storage and confirming everything works, old order copies in
wp_postsandwp_postmetacan be cleaned up through WooCommerce's own settings. - Old variation and product meta: Leftovers from deleted products are a common source of postmeta bloat.
Database Cleanup Plugin vs Manual Optimization
| Approach | Good for | Limits |
|---|---|---|
| Cleanup plugin | Revisions, transients, spam, scheduled cleanup | Cannot judge which custom tables or autoloaded options are safe to remove |
| Manual (SQL / phpMyAdmin) | Orphaned data, plugin leftovers, autoload tuning, WooCommerce tables | Needs experience and a reliable backup |
| Expert service | Large or business-critical sites and WooCommerce stores | Paid, but includes backup, testing and a report |
Once you reduce WordPress database size, keep it that way: limit revisions, set log retention to 30 days and run a light cleanup once a month. If your whole hosting account is full too, read how to free up hosting space and how to reduce WordPress website size.
WordPress Database Optimization Service
If you would rather not run SQL on a live site, I can clean and optimize your WordPress or WooCommerce database for you:
- Full database backup before any change
- Table-by-table size audit with a before/after report
- Revisions, transients, spam, orphaned meta and old logs removed
- Autoloaded options reviewed and tuned
- Leftover plugin tables identified and removed safely
- WooCommerce Action Scheduler and session cleanup
- Site tested after cleanup, including checkout
What clients said about my database optimization work:
"Great custom work - website is very well sped up!"
Client from the United States
"Was an absolute pleasure working with Juwel... got my problem sorted out in no time!!"
Client from the United Kingdom
"As usual, top service."
Repeat client from the United Kingdom
Frequently Asked Questions
Is it safe to reduce WordPress database size?
Will cleaning the database speed up my site?
What is a normal WordPress database size?
Can I delete all transients?
Will WooCommerce orders be deleted?
How often should I optimize the database?
Is Your Database Slowing Your Site Down?
Send me your website URL. I will check your database size and largest tables and tell you how much can be cleaned, free of charge.
Email Me: [email protected] Visit Web Relife