<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>database cleanup Archives - Backup Copilot</title>
	<atom:link href="https://backupcopilotplugin.com/blog/tag/database-cleanup/feed/" rel="self" type="application/rss+xml" />
	<link>https://backupcopilotplugin.com/blog/tag/database-cleanup/</link>
	<description>WordPress Backups Done Right</description>
	<lastBuildDate>Mon, 24 Nov 2025 11:17:04 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://storage.googleapis.com/backupcopilotplugin/2025/11/favicon-alt-150x150.png</url>
	<title>database cleanup Archives - Backup Copilot</title>
	<link>https://backupcopilotplugin.com/blog/tag/database-cleanup/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>WordPress Database Optimization Before Backups: Speed and Size Reduction</title>
		<link>https://backupcopilotplugin.com/blog/wordpress-database-optimization-before-backups-speed-and-size-reduction/</link>
		
		<dc:creator><![CDATA[Krasen Slavov]]></dc:creator>
		<pubDate>Sun, 30 Nov 2025 22:21:44 +0000</pubDate>
				<category><![CDATA[WordPress Performance]]></category>
		<category><![CDATA[database cleanup]]></category>
		<category><![CDATA[database optimization]]></category>
		<category><![CDATA[mysql optimization]]></category>
		<category><![CDATA[reduce backup size]]></category>
		<category><![CDATA[wordpress database]]></category>
		<guid isPermaLink="false">https://backupcopilotplugin.com/?p=228</guid>

					<description><![CDATA[<p>A bloated WordPress database slows everything down—backups take forever to create, cloud uploads time out, and restoration drags on for 30+ minutes when you need your site back online immediately.</p>
<p>The post <a href="https://backupcopilotplugin.com/blog/wordpress-database-optimization-before-backups-speed-and-size-reduction/">WordPress Database Optimization Before Backups: Speed and Size Reduction</a> appeared first on <a href="https://backupcopilotplugin.com">Backup Copilot</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>A bloated WordPress database slows everything down—backups take forever to create, cloud uploads time out, and restoration drags on for 30+ minutes when you need your site back online immediately. Worse, you&#8217;re paying for cloud storage to backup spam comments, post revisions you&#8217;ll never use, and expired transients that serve no purpose.</p>



<p>Database optimization isn&#8217;t just about site performance—it directly impacts backup efficiency. This comprehensive guide teaches you how to identify and eliminate database bloat, reducing backup sizes by 30-70% while dramatically improving backup and restore speeds.</p>



<p>By the end of this tutorial, you&#8217;ll know exactly what&#8217;s consuming database space, which tables are safe to clean, and how to implement automated optimization that keeps your database lean and your backups fast.</p>



<h2 class="wp-block-heading" id="why-database-optimization-matters-for-backups">Why Database Optimization Matters for Backups</h2>



<h3 class="wp-block-heading" id="impact-on-backup-performance">Impact on Backup Performance</h3>



<p><strong>Before Optimization:</strong></p>



<ul class="wp-block-list">
<li>Database size: 500 MB</li>



<li>Backup creation time: 8 minutes</li>



<li>Cloud upload time: 15 minutes</li>



<li>Total backup time: 23 minutes</li>
</ul>



<p><strong>After Optimization:</strong></p>



<ul class="wp-block-list">
<li>Database size: 150 MB (70% reduction)</li>



<li>Backup creation time: 2 minutes</li>



<li>Cloud upload time: 4 minutes</li>



<li>Total backup time: 6 minutes</li>
</ul>



<p><strong>That&#8217;s 4x faster backups from simple cleanup.</strong></p>



<h3 class="wp-block-heading" id="storage-cost-savings">Storage Cost Savings</h3>



<p><strong>Example E-Commerce Site:</strong></p>



<p><strong>Before optimization:</strong></p>



<ul class="wp-block-list">
<li>Database: 2 GB per backup</li>



<li>Retention: 30 daily backups</li>



<li>Total storage: 60 GB</li>



<li>Cloud cost (Dropbox): $11.99/month (2 TB plan)</li>
</ul>



<p><strong>After optimization:</strong></p>



<ul class="wp-block-list">
<li>Database: 400 MB per backup</li>



<li>Retention: 30 daily backups</li>



<li>Total storage: 12 GB</li>



<li>Cloud cost (Google Drive): $1.99/month (100 GB plan)</li>
</ul>



<p><strong>Savings: $10/month = $120/year</strong></p>



<h3 class="wp-block-heading" id="faster-disaster-recovery">Faster Disaster Recovery</h3>



<p>When your site crashes, every minute counts:</p>



<ul class="wp-block-list">
<li>150 MB database: 3 minutes to download + import</li>



<li>500 MB database: 12 minutes to download + import</li>
</ul>



<p><strong>Optimized database = 4x faster recovery</strong></p>



<h2 class="wp-block-heading" id="identifying-database-bloat">Identifying Database Bloat</h2>



<h3 class="wp-block-heading" id="check-total-database-size">Check Total Database Size</h3>



<p><strong>Via phpMyAdmin:</strong></p>



<ol class="wp-block-list">
<li>Log into phpMyAdmin</li>



<li>Click database name in left sidebar</li>



<li>Bottom of page shows &#8220;Database: database_name (X MB)&#8221;</li>
</ol>



<p><strong>Via MySQL Command:</strong></p>



<pre class="wp-block-code"><code>SELECT
    table_schema AS 'Database',
    ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS 'Size (MB)'
FROM information_schema.tables
WHERE table_schema = 'your_database_name'
GROUP BY table_schema;
</code></pre>



<p><strong>Typical WordPress Database Sizes:</strong></p>



<ul class="wp-block-list">
<li>Fresh WordPress install: ~1 MB</li>



<li>Small blog (50 posts): 5-15 MB</li>



<li>Business site (200 pages): 20-50 MB</li>



<li>E-commerce (1000 products): 50-200 MB</li>



<li>Large site (5000+ posts): 200-500 MB</li>
</ul>



<p><strong>If your site is small but database is large (100+ MB), significant bloat exists.</strong></p>



<h3 class="wp-block-heading" id="table-by-table-analysis">Table-by-Table Analysis</h3>



<p><strong>Find largest tables:</strong></p>



<pre class="wp-block-code"><code>SELECT
    table_name AS 'Table',
    ROUND(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)'
FROM information_schema.tables
WHERE table_schema = 'your_database_name'
ORDER BY (data_length + index_length) DESC
LIMIT 10;
</code></pre>



<p><strong>Common bloat culprits:</strong></p>



<ul class="wp-block-list">
<li><code>wp_postmeta</code> &#8211; Oversized from revisions</li>



<li><code>wp_options</code> &#8211; Transients and autoload bloat</li>



<li><code>wp_comments</code> &#8211; Spam comments</li>



<li><code>wp_commentmeta</code> &#8211; Orphaned comment metadata</li>



<li>Plugin tables &#8211; Logs, analytics, caches</li>
</ul>



<h3 class="wp-block-heading" id="specific-bloat-queries">Specific Bloat Queries</h3>



<p><strong>Count post revisions:</strong></p>



<pre class="wp-block-code"><code>SELECT COUNT(*) FROM wp_posts WHERE post_type = 'revision';
</code></pre>



<p>More than 1,000? Time to clean.</p>



<p><strong>Count spam comments:</strong></p>



<pre class="wp-block-code"><code>SELECT COUNT(*) FROM wp_comments WHERE comment_approved = 'spam';
</code></pre>



<p><strong>Count expired transients:</strong></p>



<pre class="wp-block-code"><code>SELECT COUNT(*)
FROM wp_options
WHERE option_name LIKE '_transient_timeout_%'
  AND option_value &lt; UNIX_TIMESTAMP();
</code></pre>



<p><strong>Count autoloaded data:</strong></p>



<pre class="wp-block-code"><code>SELECT SUM(LENGTH(option_value)) / 1024 as 'Autoload Size (KB)'
FROM wp_options
WHERE autoload = 'yes';
</code></pre>



<p>Over 1 MB (1024 KB) autoloaded = performance issue.</p>



<h2 class="wp-block-heading" id="safe-database-cleanup-methods">Safe Database Cleanup Methods</h2>



<h3 class="wp-block-heading" id="1-remove-post-revisions">1. Remove Post Revisions</h3>



<p><strong>Post revisions accumulate quickly:</strong></p>



<ul class="wp-block-list">
<li>100 posts × 10 revisions each = 1,000 extra posts</li>



<li>Each revision duplicates content, increasing database size</li>
</ul>



<p><strong>Limit future revisions in wp-config.php:</strong></p>



<pre class="wp-block-code"><code><em>// Limit to 3 revisions per post</em>
define('WP_POST_REVISIONS', 3);

<em>// Or disable revisions completely</em>
define('WP_POST_REVISIONS', false);
</code></pre>



<p><strong>Delete old revisions (keep last 3):</strong></p>



<pre class="wp-block-code"><code>DELETE a,b,c
FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
  AND a.ID NOT IN (
    SELECT ID FROM (
      SELECT p.ID
      FROM wp_posts p
      WHERE p.post_type = 'revision'
      ORDER BY p.post_modified DESC
      LIMIT 3
    ) AS keep_revisions
  );
</code></pre>



<p><strong>Use WP-CLI (safer):</strong></p>



<pre class="wp-block-code"><code>wp post delete $(wp post list --post_type='revision' --format=ids) --force
</code></pre>



<p><strong>Impact:</strong>&nbsp;Can reduce database size by 20-40% for content-heavy sites.</p>



<h3 class="wp-block-heading" id="2-clean-auto-drafts">2. Clean Auto-Drafts</h3>



<p><strong>Auto-drafts = unpublished drafts saved automatically:</strong></p>



<p><strong>Delete auto-drafts older than 30 days:</strong></p>



<pre class="wp-block-code"><code>DELETE FROM wp_posts
WHERE post_status = 'auto-draft'
  AND post_modified &lt; DATE_SUB(NOW(), INTERVAL 30 DAY);
</code></pre>



<p><strong>Via WP-CLI:</strong></p>



<pre class="wp-block-code"><code>wp post delete $(wp post list --post_status=auto-draft --format=ids) --force
</code></pre>



<h3 class="wp-block-heading" id="3-remove-spam-and-trashed-comments">3. Remove Spam and Trashed Comments</h3>



<p><strong>Spam comments accumulate in database even after marking as spam:</strong></p>



<p><strong>Delete spam comments:</strong></p>



<pre class="wp-block-code"><code>DELETE FROM wp_comments WHERE comment_approved = 'spam';
</code></pre>



<p><strong>Delete trashed comments:</strong></p>



<pre class="wp-block-code"><code>DELETE FROM wp_comments WHERE comment_approved = 'trash';
</code></pre>



<p><strong>Delete orphaned comment metadata:</strong></p>



<pre class="wp-block-code"><code>DELETE FROM wp_commentmeta
WHERE comment_id NOT IN (SELECT comment_id FROM wp_comments);
</code></pre>



<p><strong>WP-CLI method:</strong></p>



<pre class="wp-block-code"><code>wp comment delete $(wp comment list --status=spam --format=ids) --force
wp comment delete $(wp comment list --status=trash --format=ids) --force
</code></pre>



<p><strong>Impact:</strong>&nbsp;Reduces database 5-15% for sites with active comments.</p>



<h3 class="wp-block-heading" id="4-clean-expired-transients">4. Clean Expired Transients</h3>



<p><strong>Transients = temporary cached data:</strong></p>



<ul class="wp-block-list">
<li>API responses cached for 12 hours</li>



<li>Widget output cached for 24 hours</li>



<li>Plugin settings cached temporarily</li>
</ul>



<p><strong>Problem:</strong>&nbsp;Expired transients remain in database.</p>



<p><strong>Delete expired transients:</strong></p>



<pre class="wp-block-code"><code>DELETE FROM wp_options
WHERE option_name LIKE '_transient_timeout_%'
  AND option_value &lt; UNIX_TIMESTAMP();

DELETE FROM wp_options
WHERE option_name LIKE '_transient_%'
  AND option_name NOT LIKE '_transient_timeout_%'
  AND option_name NOT IN (
    SELECT REPLACE(option_name, '_transient_timeout_', '_transient_')
    FROM wp_options
    WHERE option_name LIKE '_transient_timeout_%'
  );
</code></pre>



<p><strong>Simpler plugin method:</strong>&nbsp;Install Transient Cleaner plugin, click &#8220;Clean Transients.&#8221;</p>



<p><strong>Impact:</strong>&nbsp;Reduces wp_options table by 10-30% for sites with many plugins.</p>



<h3 class="wp-block-heading" id="5-remove-orphaned-post-metadata">5. Remove Orphaned Post Metadata</h3>



<p><strong>Orphaned postmeta = metadata for deleted posts:</strong></p>



<p><strong>Find orphaned postmeta:</strong></p>



<pre class="wp-block-code"><code>SELECT COUNT(*)
FROM wp_postmeta
WHERE post_id NOT IN (SELECT ID FROM wp_posts);
</code></pre>



<p><strong>Delete orphaned postmeta:</strong></p>



<pre class="wp-block-code"><code>DELETE FROM wp_postmeta
WHERE post_id NOT IN (SELECT ID FROM wp_posts);
</code></pre>



<p><strong>Impact:</strong>&nbsp;Can recover 5-10 MB in moderately sized databases.</p>



<h3 class="wp-block-heading" id="6-optimize-autoloaded-options">6. Optimize Autoloaded Options</h3>



<p><strong>Autoload = data loaded on every page request:</strong></p>



<p><strong>View largest autoloaded options:</strong></p>



<pre class="wp-block-code"><code>SELECT
    option_name,
    LENGTH(option_value) AS 'Size (bytes)',
    ROUND(LENGTH(option_value) / 1024, 2) AS 'Size (KB)'
FROM wp_options
WHERE autoload = 'yes'
ORDER BY LENGTH(option_value) DESC
LIMIT 20;
</code></pre>



<p><strong>Disable autoload for large, infrequently-used options:</strong></p>



<pre class="wp-block-code"><code>UPDATE wp_options
SET autoload = 'no'
WHERE option_name = 'large_option_name'
  AND LENGTH(option_value) &gt; 50000;
</code></pre>



<p><strong>Warning:</strong>&nbsp;Only disable autoload if you understand what the option does. Some options must be autoloaded.</p>



<p><strong>Impact:</strong>&nbsp;Improves site performance, minimal database size reduction.</p>



<h2 class="wp-block-heading" id="using-optimization-plugins">Using Optimization Plugins</h2>



<h3 class="wp-block-heading" id="wp-optimize-recommended">WP-Optimize (Recommended)</h3>



<p><strong>Features:</strong></p>



<ul class="wp-block-list">
<li>Clean revisions, drafts, spam with one click</li>



<li>Schedule automatic weekly optimization</li>



<li>Table optimization (OPTIMIZE TABLE)</li>



<li>Image compression (premium)</li>



<li>Safe and actively maintained</li>
</ul>



<p><strong>Installation:</strong></p>



<ol class="wp-block-list">
<li>Plugins > Add New > Search &#8220;WP-Optimize&#8221;</li>



<li>Install and activate</li>



<li>WP-Optimize > Database tab</li>



<li>Check desired cleanup actions</li>



<li>Click &#8220;Run optimization&#8221;</li>
</ol>



<p><strong>Recommended settings:</strong></p>



<ul class="wp-block-list">
<li>Clean post revisions: Yes</li>



<li>Clean auto-drafts: Yes</li>



<li>Clean spam/trashed comments: Yes</li>



<li>Clean expired transients: Yes</li>



<li>Optimize tables: Yes</li>



<li>Schedule: Weekly</li>
</ul>



<h3 class="wp-block-heading" id="advanced-database-cleaner">Advanced Database Cleaner</h3>



<p><strong>Features:</strong></p>



<ul class="wp-block-list">
<li>Clean orphaned data from deleted plugins</li>



<li>Remove unused tables</li>



<li>Optimize and repair tables</li>



<li>Schedule cleanups</li>
</ul>



<p><strong>Best for:</strong>&nbsp;Sites that install/uninstall many plugins (leaves orphaned tables).</p>



<h3 class="wp-block-heading" id="wp-sweep">WP-Sweep</h3>



<p><strong>Features:</strong></p>



<ul class="wp-block-list">
<li>Similar to WP-Optimize</li>



<li>Detailed statistics before cleanup</li>



<li>Integrates with WP-CLI</li>
</ul>



<p><strong>Use if:</strong>&nbsp;You want detailed preview before cleanup.</p>



<h2 class="wp-block-heading" id="manual-database-optimization">Manual Database Optimization</h2>



<h3 class="wp-block-heading" id="optimize-table-command">OPTIMIZE TABLE Command</h3>



<p><strong>What it does:</strong></p>



<ul class="wp-block-list">
<li>Reclaims unused space</li>



<li>Defragments table data</li>



<li>Rebuilds indexes</li>



<li>Improves query performance</li>
</ul>



<p><strong>Optimize all WordPress tables:</strong></p>



<pre class="wp-block-code"><code>OPTIMIZE TABLE
    wp_posts,
    wp_postmeta,
    wp_options,
    wp_comments,
    wp_commentmeta,
    wp_users,
    wp_usermeta,
    wp_terms,
    wp_term_taxonomy,
    wp_term_relationships,
    wp_termmeta;
</code></pre>



<p><strong>Via phpMyAdmin:</strong></p>



<ol class="wp-block-list">
<li>Select database</li>



<li>Check all tables</li>



<li>Bottom dropdown: &#8220;Optimize table&#8221;</li>



<li>Click &#8220;Go&#8221;</li>
</ol>



<p><strong>WP-CLI method:</strong></p>



<pre class="wp-block-code"><code>wp db optimize
</code></pre>



<p><strong>Frequency:</strong>&nbsp;Monthly for active sites, quarterly for static sites.</p>



<p><strong>Impact:</strong>&nbsp;Recovers 5-15% disk space from fragmentation.</p>



<h3 class="wp-block-heading" id="repair-and-optimize-combined">Repair and Optimize Combined</h3>



<p><strong>For MyISAM tables (older WordPress):</strong></p>



<pre class="wp-block-code"><code>mysqlcheck -u username -p --auto-repair --optimize database_name
</code></pre>



<p><strong>Benefits:</strong></p>



<ul class="wp-block-list">
<li>Fixes minor corruption</li>



<li>Optimizes simultaneously</li>



<li>Safe to run regularly</li>
</ul>



<h2 class="wp-block-heading" id="automated-optimization-strategies">Automated Optimization Strategies</h2>



<h3 class="wp-block-heading" id="schedule-regular-cleanups">Schedule Regular Cleanups</h3>



<p><strong>WP-Optimize built-in scheduler:</strong></p>



<ol class="wp-block-list">
<li>WP-Optimize > Settings tab</li>



<li>Enable &#8220;Schedule cleanups&#8221;</li>



<li>Choose frequency: Weekly recommended</li>



<li>Select cleanup tasks</li>



<li>Save settings</li>
</ol>



<p><strong>WP-CLI cron job:</strong></p>



<pre class="wp-block-code"><code><em># Add to server crontab</em>
0 3 * * 0 /usr/bin/wp db optimize --path=/path/to/wordpress
</code></pre>



<p>Runs every Sunday at 3 AM.</p>



<h3 class="wp-block-heading" id="pre-backup-optimization-hook">Pre-Backup Optimization Hook</h3>



<p><strong>Optimize database before each automated backup:</strong></p>



<p>Create plugin or add to functions.php:</p>



<pre class="wp-block-code"><code>add_action('before_backup_creation', 'optimize_database_before_backup');

function optimize_database_before_backup() {
    global $wpdb;

    <em>// Get all WordPress tables</em>
    $tables = $wpdb-&gt;get_col("SHOW TABLES LIKE '{$wpdb-&gt;prefix}%'");

    foreach ($tables as $table) {
        $wpdb-&gt;query("OPTIMIZE TABLE {$table}");
    }
}
</code></pre>



<p>Ensures every backup is of optimized database.</p>



<h3 class="wp-block-heading" id="plugin-specific-cleanup">Plugin-Specific Cleanup</h3>



<p><strong>WooCommerce order cleanup:</strong></p>



<p>Delete old completed orders (keep 1 year):</p>



<pre class="wp-block-code"><code>DELETE posts, postmeta
FROM wp_posts posts
LEFT JOIN wp_postmeta postmeta ON posts.ID = postmeta.post_id
WHERE posts.post_type = 'shop_order'
  AND posts.post_status = 'wc-completed'
  AND posts.post_date &lt; DATE_SUB(NOW(), INTERVAL 1 YEAR);
</code></pre>



<p><strong>Warning:</strong>&nbsp;Only if certain you don&#8217;t need old order records for accounting/tax purposes.</p>



<h2 class="wp-block-heading" id="measuring-optimization-results">Measuring Optimization Results</h2>



<h3 class="wp-block-heading" id="beforeafter-comparison">Before/After Comparison</h3>



<p><strong>Before optimization, record:</strong></p>



<pre class="wp-block-code"><code><em>-- Total database size</em>
SELECT SUM(data_length + index_length) / 1024 / 1024 AS 'Size (MB)'
FROM information_schema.tables
WHERE table_schema = 'your_database';

<em>-- Row counts</em>
SELECT COUNT(*) FROM wp_posts WHERE post_type = 'revision';
SELECT COUNT(*) FROM wp_comments WHERE comment_approved = 'spam';
SELECT COUNT(*) FROM wp_options WHERE option_name LIKE '_transient_%';
</code></pre>



<p><strong>After optimization, compare:</strong></p>



<ul class="wp-block-list">
<li>Database size reduction (MB)</li>



<li>Revision count reduction</li>



<li>Spam comment removal</li>



<li>Transient cleanup</li>
</ul>



<p><strong>Example results:</strong></p>



<pre class="wp-block-code"><code>Before: 450 MB database, 5,200 revisions, 12,000 spam comments
After: 180 MB database, 300 revisions, 0 spam comments
Reduction: 60% size reduction, 270 MB saved
</code></pre>



<h3 class="wp-block-heading" id="backup-time-improvement">Backup Time Improvement</h3>



<p><strong>Test backup before and after:</strong></p>



<p>Before optimization:</p>



<pre class="wp-block-code"><code>Start: 3:00:00 AM
Finish: 3:12:45 AM
Duration: 12 minutes 45 seconds
File size: 450 MB
</code></pre>



<p>After optimization:</p>



<pre class="wp-block-code"><code>Start: 3:00:00 AM
Finish: 3:04:20 AM
Duration: 4 minutes 20 seconds
File size: 180 MB
</code></pre>



<p><strong>Improvement: 66% faster backups, 60% smaller files</strong></p>



<h2 class="wp-block-heading" id="best-practices-and-warnings">Best Practices and Warnings</h2>



<h3 class="wp-block-heading" id="safety-precautions">Safety Precautions</h3>



<p><strong>Always backup before optimization:</strong></p>



<ol class="wp-block-list">
<li>Create full database backup</li>



<li>Download backup locally</li>



<li>Verify backup file size reasonable</li>



<li>Then run optimization</li>



<li>If something breaks, restore from backup</li>
</ol>



<p><strong>Test on staging first:</strong></p>



<ul class="wp-block-list">
<li>Clone site to staging environment</li>



<li>Run optimization on staging</li>



<li>Verify site functions correctly</li>



<li>Then optimize production</li>
</ul>



<p><strong>Never run unknown SQL:</strong></p>



<ul class="wp-block-list">
<li>Don&#8217;t copy/paste SQL from untrusted sources</li>



<li>Understand what each query does</li>



<li>Test on small subset first</li>



<li>Have backup before executing</li>
</ul>



<h3 class="wp-block-heading" id="what-not-to-clean">What NOT to Clean</h3>



<p><strong>Do NOT delete:</strong></p>



<ul class="wp-block-list">
<li><code>wp_options</code> with autoload=&#8217;yes&#8217; (unless you know what it is)</li>



<li><code>wp_users</code> or <code>wp_usermeta</code> (breaks user accounts)</li>



<li><code>wp_posts</code> with post_status=&#8217;publish&#8217; (deletes published content)</li>



<li>Custom plugin tables without understanding purpose</li>



<li>Any table if unsure what it does</li>
</ul>



<p><strong>When in doubt, keep it.</strong></p>



<h3 class="wp-block-heading" id="optimization-frequency">Optimization Frequency</h3>



<p><strong>Recommended schedule:</strong></p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Site Type</th><th>Optimization Frequency</th></tr></thead><tbody><tr><td>Personal blog</td><td>Quarterly (every 3 months)</td></tr><tr><td>Business site</td><td>Monthly</td></tr><tr><td>E-commerce</td><td>Weekly</td></tr><tr><td>High-traffic</td><td>Weekly</td></tr><tr><td>Membership</td><td>Bi-weekly</td></tr></tbody></table></figure>



<p><strong>Before major events:</strong></p>



<ul class="wp-block-list">
<li>Before site redesign</li>



<li>Before migration</li>



<li>Before Black Friday (e-commerce)</li>



<li>Before product launch</li>
</ul>



<h2 class="wp-block-heading" id="real-world-optimization-example">Real-World Optimization Example</h2>



<p><strong>Site:</strong>&nbsp;Food blog with 500 posts, 3 years old</p>



<p><strong>Initial stats:</strong></p>



<ul class="wp-block-list">
<li>Database size: 680 MB</li>



<li>Backup time: 18 minutes</li>



<li>Revisions: 8,200</li>



<li>Spam comments: 24,000</li>



<li>Expired transients: 1,500</li>
</ul>



<p><strong>Optimization steps:</strong></p>



<ol class="wp-block-list">
<li>Limited revisions to 3 per post</li>



<li>Deleted old revisions (kept last 3)</li>



<li>Deleted all spam comments</li>



<li>Cleaned expired transients</li>



<li>Removed orphaned postmeta</li>



<li>Optimized all tables</li>
</ol>



<p><strong>Results:</strong></p>



<ul class="wp-block-list">
<li>Database size: 195 MB (<strong>71% reduction</strong>)</li>



<li>Backup time: 5 minutes (<strong>72% faster</strong>)</li>



<li>Revisions: 600 (kept recent ones)</li>



<li>Spam comments: 0</li>



<li>Expired transients: 0</li>
</ul>



<p><strong>Ongoing maintenance:</strong></p>



<ul class="wp-block-list">
<li>WP-Optimize scheduled weekly</li>



<li>Revisions limited to 3 in wp-config.php</li>



<li>Akismet blocks spam (auto-delete after 15 days)</li>
</ul>



<p><strong>Annual savings:</strong></p>



<ul class="wp-block-list">
<li>Cloud storage downgraded: $60/year saved</li>



<li>Backup time saved: 13 minutes × 365 days = 79 hours/year</li>



<li>Faster site performance: Priceless</li>
</ul>



<h2 class="wp-block-heading" id="external-links">Related Resources</h2>



<ol class="wp-block-list">
<li><a href="https://wordpress.org/support/article/optimization/">WordPress Database Optimization</a></li>



<li><a href="https://dev.mysql.com/doc/refman/8.0/en/optimize-table.html">MySQL OPTIMIZE TABLE</a></li>



<li><a href="https://wordpress.org/plugins/wp-optimize/">WP-Optimize Plugin</a></li>



<li><a href="https://developer.wordpress.org/apis/transients/">Understanding WordPress Transients</a></li>



<li><a href="https://codex.wordpress.org/Database_Optimization">Database Performance Best Practices</a></li>
</ol>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>Cleaner databases, faster backups!&nbsp;<a href="https://backupcopilotplugin.com/#pricing">Backup Copilot Pro</a>&nbsp;backs up optimized databases efficiently with smart compression. Reduce storage costs and improve restore times—start optimizing today!</p>
<p>The post <a href="https://backupcopilotplugin.com/blog/wordpress-database-optimization-before-backups-speed-and-size-reduction/">WordPress Database Optimization Before Backups: Speed and Size Reduction</a> appeared first on <a href="https://backupcopilotplugin.com">Backup Copilot</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
