New 24/7 monitoring and daily cloud backups now included in every Shield Pro plan.

Database

Learn how to reduce WordPress database size.

A bloated database slows backups, migrations, and admin searches. wp_options and wp_postmeta grow quietly from expired transients, old Action Scheduler rows, and revision history. This tutorial trims fat without deleting orders or customers.

Time: 30-50 minutes Level: Intermediate
Neil McNaught, founder of BugShield and WordPress author
Written by
Written by
Updated
Updated

What this problem looks like

Database size rarely affects front-end speed until tables hit millions of rows. It always affects backup windows, staging sync, and admin queries on meta-heavy plugins.

Never truncate wp_posts for shops. Order and subscription data lives there. Focus on transients, logs, sessions, and revisions first.

Step 1: Find what consumes space

In phpMyAdmin, sort tables by size. Common culprits: wp_postmeta, wp_options, wp_actionscheduler_actions, wp_actionscheduler_logs, wp_comments.

The commands below need SSH access and will not work inside File Manager:

bash
wp db size --tables
wp transient delete --expired

Step 2: Safe cleanup targets

  • Post revisions beyond your retention policy.
  • Trashed posts and spam comments.
  • Expired transients in wp_options.
  • Completed Action Scheduler actions older than 30 days.
  • Large wc-logs files under wp-content/uploads/.

Step 3: WooCommerce-specific caution

Do not delete orders, subscriptions, or customer download permissions. WooCommerce → Status → Tools offers Clear expired transients and Clear customer sessions for safer session cleanup.

Step 4: Remove orphaned post meta carefully

Plugins leave orphan meta when posts delete improperly. Advanced DB Cleaner can remove orphans after backup. Run on staging first and verify shop checkout after cleanup.

Step 5: Schedule ongoing maintenance

Limit revisions in wp-config.php in your site root, next to wp-admin and wp-content. Search for WP_POST_REVISIONS and EMPTY_TRASH_DAYS first. If those lines already exist, update them instead of adding duplicates. If neither exists, paste the constants above the line that says stop editing:

php
define( 'WP_POST_REVISIONS', 5 );
define( 'EMPTY_TRASH_DAYS', 7 );

When to stop DIY and hire help

Tables over several gigabytes, corrupted indexes, or multisite networks need DBA-level help. BugShield shrinks WooCommerce databases and fixes slow meta queries at a confirmed price without hourly billing surprises.

Questions answered

Reducing WordPress database size FAQs

Answers about backups, large tables, revisions, sessions, scheduled-action logs, autoloaded options, and reclaiming space safely.

Will database cleanup speed up my site?

Moderately for admin and backups. Front-end gains are smaller unless queries were scanning huge meta tables on every page.

Is WP-Optimize safe for WooCommerce?

Use WooCommerce-aware settings. Do not enable every aggressive option without reading descriptions.

How big is too big for WordPress database?

No fixed limit. Problems appear when backups exceed hosting limits or admin queries timeout, often above 1 to 2 GB on modest hosting.

Can I delete wp_options transients manually?

Expired transients yes. Active transients break features until regenerated. Use wp transient delete --expired over SSH when possible.

Should I back up before reducing WordPress database size?

Yes. Export the database and confirm the backup is usable before deleting rows, dropping tables, or running optimisation commands.

How do I find the largest WordPress database tables?

Sort tables by data and index size in your hosting database tool or query information_schema, then identify which plugin owns each large table.

Can post revisions make a WordPress database too large?

Yes on frequently edited sites, but they are only one source. Limit future revisions and remove old ones in controlled batches after a backup.

Can WooCommerce sessions make the database large?

Expired sessions and carts can accumulate, but use WooCommerce cleanup routines and confirm current sessions are not removed during active sales.

Can Action Scheduler logs be cleaned safely?

Completed and failed action history can grow substantially. Use supported retention or cleanup tools and investigate recurring failures before deleting their evidence.

Does deleting rows immediately reduce the database file size?

Not always. The database may retain allocated space for reuse. Table optimisation can reclaim some space, but only after a backup and with enough server capacity.

Would you rather a developer fixed it?

Request a fix at a confirmed price and speak directly with the BugShield developer working on your site.

Request a Fix