Skip to content
Hire Me Login

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.

By Md Juwel Rana · Updated · 10 min read

Biggest culpritswp_options autoload, wp_postmeta, revisions, Action Scheduler logs.
Safe first stepsBack up, then clear transients, revisions, spam and trash.
ResultFaster admin, faster pages, smaller backups and migrations.
Reduce WordPress database size - clean and optimize the WordPress and WooCommerce database

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_options and 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):

SELECT table_name, ROUND((data_length + index_length) / 1024 / 1024, 2) AS size_mb FROM information_schema.tables WHERE table_schema = 'your_db_name' ORDER BY size_mb DESC LIMIT 15;

The Tables That Bloat the Most

TableWhat fills itCleanup risk
wp_optionsExpired transients, heavy autoloaded settings, plugin leftoversMedium
wp_postsRevisions, auto-drafts, trashed postsLow
wp_postmetaOrphaned meta, page builder data, old product metaMedium
wp_comments / commentmetaSpam and trashed commentsLow
wp_actionscheduler_*Completed and failed WooCommerce background jobsLow
wp_wc_sessionsExpired WooCommerce customer sessionsLow
Plugin log tablesSecurity, email, redirection and 404 logsLow
Unknown custom tablesTables from plugins you may still useHigh

How to Reduce WordPress Database Size: 8 Safe Steps

Step 0 – back up first. Export the full database from phpMyAdmin or your backup plugin and store it off the server. Database changes cannot be undone without a backup.

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.

Good to know: Deleting rows does not always shrink the file on disk right away. Optimizing the tables afterwards is what actually releases the space on InnoDB and MyISAM tables.

SQL Queries to Clean the WordPress Database (Developers)

Use these only after a full backup. Replace wp_ with your own table prefix.

-- Delete post revisions DELETE FROM wp_posts WHERE post_type = 'revision'; -- Delete expired transients DELETE a, b FROM wp_options a JOIN wp_options b ON b.option_name = REPLACE(a.option_name, '_transient_timeout_', '_transient_') WHERE a.option_name LIKE '\_transient\_timeout\_%' AND a.option_value < UNIX_TIMESTAMP(); -- Delete orphaned post meta DELETE pm FROM wp_postmeta pm LEFT JOIN wp_posts p ON p.ID = pm.post_id WHERE p.ID IS NULL; -- Delete spam and trashed comments DELETE FROM wp_comments WHERE comment_approved IN ('spam', 'trash');

Find the heaviest autoloaded options:

SELECT option_name, LENGTH(option_value) AS bytes FROM wp_options WHERE autoload IN ('yes', 'on', 'auto-on', 'auto') ORDER BY bytes DESC LIMIT 20;

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_posts and wp_postmeta can 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

ApproachGood forLimits
Cleanup pluginRevisions, transients, spam, scheduled cleanupCannot judge which custom tables or autoloaded options are safe to remove
Manual (SQL / phpMyAdmin)Orphaned data, plugin leftovers, autoload tuning, WooCommerce tablesNeeds experience and a reliable backup
Expert serviceLarge or business-critical sites and WooCommerce storesPaid, 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?
Yes, if you take a full backup first and only remove data you understand, such as revisions, expired transients, spam and orphaned meta.
Will cleaning the database speed up my site?
Usually yes. A smaller wp_options table and fewer autoloaded options make every page request lighter, especially in the admin and on WooCommerce stores.
What is a normal WordPress database size?
Small business sites are often under 50 MB. Blogs and stores can be several hundred MB. What matters most is how much of it is junk and how large the autoloaded options are.
Can I delete all transients?
Yes. Transients are temporary cache data and WordPress rebuilds them when needed. Deleting expired ones is the safest option.
Will WooCommerce orders be deleted?
No. A proper cleanup only removes logs, sessions, transients and orphaned data. Orders, customers and products stay untouched.
How often should I optimize the database?
A light cleanup once a month is enough for most sites. Busy WooCommerce stores benefit from weekly cleanup of logs and sessions.

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