reduce database size

If your WordPress database has grown unusually large (for example, from 1GB to 6GB), it usually means your website is storing unnecessary data such as logs, transients, revisions, or WooCommerce activity records.

This guide will help you safely reduce your database size without breaking your website.

⚙️ Step 1: Check Which Tables Are Large

  1. Log in to your cPanel or My20i dashboard.

  2. Open phpMyAdmin and select your WordPress database.

  3. Review the “Size” column to see which tables are the largest.

Common tables that usually grow too large include:

  • wp_actionscheduler_actions

  • wp_actionscheduler_logs

  • wp_woocommerce_sessions

  • wp_postmeta

  • wp_options

  • wp_yoast_indexable or wp_rank_math_*

💡 Tip: You can sort the tables by size to quickly locate the biggest ones.


🧹 Step 2: Clean Up Safely Using a Plugin

Install one of the following trusted plugins from your WordPress dashboard:

  • WP-Optimize (Recommended)

  • Advanced Database Cleaner

After installation:

  1. Go to the plugin’s settings.

  2. Clean the following items:

    • Post revisions

    • Auto drafts and trashed posts

    • Spam and trashed comments

    • Expired transients

  3. Click Optimize Database Tables.

⚠️ Always back up your database before cleaning. You can use plugins like UpdraftPlus or WPVivid Backup.


🧰 Step 3: Manual SQL Cleanup (Optional)

If you’re familiar with phpMyAdmin or SQL, you can safely run the following queries to remove unnecessary data.

1️⃣ WooCommerce Scheduled Actions

DELETE FROM wp_actionscheduler_logs;
DELETE FROM wp_actionscheduler_actions
WHERE status='complete' AND scheduled_date_gmt < NOW() - INTERVAL 30 DAY;
OPTIMIZE TABLE wp_actionscheduler_actions;
OPTIMIZE TABLE wp_actionscheduler_logs;

2️⃣ WooCommerce Sessions

DELETE FROM wp_woocommerce_sessions
WHERE session_expiry < UNIX_TIMESTAMP();
OPTIMIZE TABLE wp_woocommerce_sessions;

3️⃣ Old Transients

DELETE FROM wp_options
WHERE option_name LIKE '_transient_%'
OR option_name LIKE '_site_transient_%';
OPTIMIZE TABLE wp_options;

These queries remove expired or completed logs, sessions, and cached data that WordPress no longer needs.


🧾 Step 4: Limit Future Database Growth

To prevent your database from growing too large again, add these lines to your wp-config.php file (above the line that says “That’s all, stop editing!”):

define('WP_POST_REVISIONS', 5); // Keep only 5 revisions per post
define('AUTOSAVE_INTERVAL', 300); // Autosave every 5 minutes
define('EMPTY_TRASH_DAYS', 7); // Empty trash weekly

🧠 Step 5: Maintain Regular Optimization

  • Schedule WP-Optimize or Advanced Database Cleaner to run weekly.

  • Regularly delete spam, trash, and expired transients.

  • If your hosting plan supports it, enable Redis or Memcached object caching to reduce database load.


✅ Summary

By following the steps above, you can:

  • Reclaim several gigabytes of disk space

  • Improve your website speed and performance

  • Prevent future database bloating


Need Assistance?
If you’re not comfortable performing these steps yourself, our team can help.
Submit a ticket via your client area at support.intekhost.net and our support engineers will assist you in safely optimizing your WordPress database.