Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
FREEDOM251

Freedom251 › Blog › backups

How to Reduce the Database Size of a WordPress Site Safely

By Freedom251 Team · · 9 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The safest way to reduce a WordPress database is to back up the database and site files, measure which tables and options are large, remove only confirmed disposable records, optimize the tables, and then test the site. Cleanup and table optimization are different jobs: deleting revisions or expired transients removes rows, while optimization asks the database engine to reorganize or reclaim storage.

What reducing a WordPress database actually changes

A WordPress database contains posts, pages, comments, users, settings and plugin data. Its apparent size can grow for several different reasons: years of revisions, discarded drafts, comment spam, temporary cache records, oversized settings, or tables left behind by an uninstalled plugin. Those causes require different remedies.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A smaller database dump is useful for backups and migrations, but size alone does not determine front-end speed. The most important performance-focused area is usually autoloaded data in wp_options. Autoloaded options are loaded on normal requests, so an oversized set can increase memory use and query work even when the rest of the database is modest.

There is no universal safe target in megabytes. The possible reduction depends on revision history, comment volume, plugin tables, transient churn, indexes, the database engine and how long backups must be retained.

#1 Best Overall
Vehicle Maintenance Log Book, 110 Car Maintenance & Expense Tracker Record Sheets Plus 36 Service Due Stickers, Car Repair & Service Record Spiral Binding Logbook (5.5” x 7.1”)
  • 110 Sheets Log Book: This vehicle maintenance log book includes 110 record sheets to track repairs, services, fuel costs, and other vehicle-related expenses. It also comes with 36 convenient “Service Due” stickers to help remind you of upcoming maintenance schedules. Everything you need to keep your car records organized in one place.
  • Detailed Information: Each page is carefully structured with dedicated sections for date, mileage, service description, parts replaced, vehicle information, cost, and additional notes. The clear and organized format allows you to maintain accurate records, monitor repair history, and better manage long-term vehicle performance and expenses.
  • Enough Writing Space: The record sheets provide ample space for clear and thorough entries. Whether you’re documenting routine oil changes or major repairs, there’s plenty of room to write detailed information without feeling cramped.
  • Easy to Use: The spiral binding allows the notebook to lay flat for comfortable writing, making entries quick and convenient. The included 36 “Service Due” stickers can be placed inside the book or on visible surfaces like your windshield or dashboard, helping you keep important maintenance reminders in sight.
  • Proper Size: This compact logbook measures 5.5” x 7.1”, which fits easily in your glove compartment, center console, backpack, or desk drawer. Its portable size ensures you can access and update your vehicle records anytime, whether at home, in the garage, or at the service center.

Back up everything before deleting records

WordPress explains that a database export contains posts, pages, comments and settings, but not themes, plugins, uploads or other site files. Keep a database backup and a separate file backup together, and store at least one copy off-site.

  1. Put the site in a maintenance window if it receives orders, registrations or frequent comments.
  2. Export the database. With WP-CLI, a typical command is wp db export wordpress-before-cleanup.sql. Your host’s control panel or database administration tool can also create an SQL export.
  3. Back up wp-content (including uploads, themes and plugins) and wp-config.php. Preserve any server-level configuration your deployment needs.
  4. Copy both backups to storage separate from the web server. An external drive can be part of the plan, but choose its capacity from the size and retention period of the complete backup set rather than from the database alone.
  5. Confirm that the export can be opened or restored in a staging environment. A backup that was never checked is not a reliable rollback plan.

If the site is important, make a fresh staging clone and perform the cleanup there first. Do not run destructive SQL on production while an editor, checkout, import or scheduled job is actively writing data.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Measure the baseline before changing data

Record the total database size, each table’s size and row count, and the largest values in wp_options. Record the table prefix from wp-config.php; it may not be wp_.

Using WP-CLI

  • wp db size --tables reports database and table sizes on installations where the command is available.
  • wp db query "SHOW TABLE STATUS" exposes row estimates and storage columns for a closer table-by-table baseline.
  • wp option list --autoload=on --fields=option_name,autoload,size_bytes --format=table can help identify autoloaded options on WP-CLI versions that provide the size_bytes field. If that field is unavailable, query the database directly.

SQL checks for table and option hotspots

Run read-only queries first. Replace wp_ with your actual prefix.

SELECT table_name,
       table_rows,
       data_length,
       index_length,
       (data_length + index_length) AS total_bytes
FROM information_schema.tables
WHERE table_schema = DATABASE()
ORDER BY total_bytes DESC;

To inspect large autoloaded values, use a length calculation rather than printing the complete serialized content:

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

Autoload values can contain serialized arrays, so never edit a serialized string by hand unless you understand its format. A malformed value can make a plugin or theme fail to load.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Clean records that are genuinely disposable

Use the categories below as an audit list, not as permission to delete every matching row. Keep a second backup until the site has operated normally after the change.

Rank #2
Sale
LKTHSEEK Equipment Maintenance Log Book 8.5 x 11 Inch 110 Pages Maintenance Record Notebook Tracking Repairs and Service Spiral Bound For Equipment Inspection and Maintenance
  • All In One Equipment Maintenance Log Book With Detailed Fields:This equipment maintenance log book is designed for complete tracking of machinery and equipment performance Featuring pre-printed sections for Equipment Name Manufacturer Name Model Number Serial Number Purchase Date Item Location and Additional Information this repair log book ensures accurate and consistent service records
  • Includes Maintenance Schedule Fields for Time and Task Recording:Each page includes dedicated spaces for Date and Time Maintenance Task or Remarks Performed By and Cost helping you record maintenance frequency track service intervals and monitor expenses Ideal for preventive maintenance logs and repair history documentation
  • Large Format Repair Log Book With Continuation Pages:Sized at 8.5 x 11 inches this equipment service record notebook provides generous space for writing and includes 110 Pages with continuation pages to extend entries when needed Ensures that even complex service reports are kept complete and organized
  • Durable Spiral Bound Construction for Long Term Use:Built with a 300gsm laminated cover and strong spiral binding this maintenance log notebook lies flat for easy writing and endures frequent handling in demanding environments from factory floors to fieldwork sites
  • Ideal for Industrial Commercial and Personal Equipment Tracking:Whether you’re managing heavy machinery in construction agricultural tools in farming or facility systems in schools or warehouses this maintenance record book helps technicians engineers and facility managers maintain consistent and accessible logs

Post revisions

Revisions support rollback in the editor, but a busy site can accumulate thousands. Decide how much history editors actually need. Keeping a deliberate number is safer than deleting all revisions blindly. A common preventive setting is a finite revision limit in wp-config.php, but set it according to your editorial workflow and test it on staging.

WP-CLI can list revisions with wp post list --post_type=revision. Delete only the IDs you have reviewed, using wp post delete <ID> --force. For a large, well-understood batch, use a staging-tested script and keep the export made immediately before deletion.

Auto-drafts and trashed posts

Auto-drafts are temporary posts created while an editor starts a new item. Trashed posts are retained for recovery until the trash is emptied. Confirm that no editor needs the content, then permanently delete the selected items. The WordPress admin can empty post trash; WP-CLI can target a reviewed list of post IDs with wp post delete.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Spam and trashed comments

Comment spam and trashed comments can consume substantial space on sites that receive automated submissions. Check moderation and legal-retention requirements first, then empty the relevant comment queues. Preserve legitimate comments and any records needed for abuse investigations.

Expired transients

Transients are temporary cached values. Without a persistent object cache, they are commonly stored in wp_options. Expired transients can leave rows behind even when they are not autoloaded. Removing expired entries is normally low risk because active code can recreate a transient, but a temporary cache miss may make the next request slower.

Do not interpret recurring transients as proof that cleanup failed. A plugin that is still active may recreate them by design. If a transient is continually huge or recreated at an excessive rate, investigate the owning plugin instead of scheduling increasingly aggressive deletion.

Orphaned plugin and theme data

Uninstalling a plugin does not always remove its custom tables, options or scheduled-job records. Delete such data only when the plugin’s uninstall routine or documentation confirms that it is safe, or when you have identified the owner and verified the data is no longer used. An unfamiliar option name is not evidence that it is orphaned.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Take special care with ecommerce, membership, form, analytics and multilingual plugins: their tables may not resemble core WordPress tables, and removing them can destroy historical orders, submissions or configuration.

Audit autoloaded options in wp_options

WordPress’s Developer Handbook gives a general performance guideline: “Generally, you should try to keep your site’s autoloaded options under 800kb.” This is guidance, not a universal hard limit. A site with a different workload or object-cache setup may behave differently, but a much larger value deserves investigation.

  1. Run the size query and sort by bytes.
  2. For each large option, identify its owner from the option name, the plugin or theme source, documentation, or a staging test. Serialized content may reveal a component name, but do not alter it manually.
  3. Determine whether the option is required on every request, required only in administration, temporary, or left over from a removed component.
  4. Disable or delete only an option confirmed to be unused. If it belongs to an active component, use that component’s settings or uninstall procedure rather than a direct SQL delete.
  5. Recheck the autoload total and test the pages that use the component.

WordPress 6.6 introduced behavior that can skip autoloading for large options when no explicit autoload value is supplied. That behavior does not make arbitrary deletion safe, and it does not remove the need to audit older options whose autoload value is explicitly enabled.

Choose a cleanup method that matches your risk

Method What it can do Important limitation Best use
WordPress admin Empty post and comment trash, review content and change plugin settings Core screens do not expose every plugin table or oversized option Small, visible cleanups by site owners
WP-CLI Export the database, list and delete selected posts, inspect options, and run table optimization It does not decide which records are safe to delete; recurring scheduling and restore workflows are not stated in the WP-CLI table-optimization documentation Repeatable, reviewable work by an administrator with shell access
SQL or database administration tools Inspect exact rows and table statistics and perform targeted deletes A syntax or prefix mistake can damage production data; SQL does not understand a plugin’s ownership rules Experienced operators working from a tested script and verified backup
WP-Optimize Its documentation describes cleanup for revisions, auto-drafts, trashed posts, spam and trashed comments, transients and database tables, plus backup-before-cleanup support Plugin-owned orphan data still requires ownership checks, and a backup feature is not a substitute for an independently retained copy Guided cleanup when you want a UI and pre-cleanup backup option

Whichever method you choose, preview the records or run the operation on staging first. A tool can automate selection, but it cannot know whether a particular revision, comment or custom option has business value.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Optimize tables only after deleting data

Once disposable records are removed, table optimization may reclaim free space or reorganize data, depending on the storage engine. With WP-CLI, wp db optimize runs mysqlcheck with --optimize=true. This command does not select revisions, transients or orphaned plugin rows; it operates on tables as tables.

Run optimization during a quiet period and check your host’s guidance for locking or resource limits. On a large production database it can consume disk space temporarily, use CPU and hold locks. Measure table sizes again afterward rather than assuming every deleted row immediately reduces the file size.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Verify the site and keep the rollback path

After cleanup and optimization, compare the new table report with your baseline. Then test both ordinary requests and workflows that write data:

  • Log in and out, open the dashboard, and edit and publish a test post.
  • Submit forms and confirm email or webhook delivery.
  • Post, moderate and search comments if comments are enabled.
  • Run a checkout, account, subscription or order-status test on an ecommerce site.
  • Check scheduled tasks, imports, feeds, search indexing and media uploads.
  • Open settings pages for every plugin whose options or tables were touched.
  • Review PHP, web-server and WordPress logs for database errors, missing-table messages and unserialize warnings.

Keep the pre-cleanup database and file backups until the site has completed a normal operating cycle, including scheduled jobs and at least one real content change. If a feature fails, restore the database and files as a matched set, then identify the specific deleted record or plugin-owned table before attempting a narrower cleanup.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Prevent the database from growing back

  • Set a revision policy that preserves the rollback history editors need instead of allowing unlimited accumulation.
  • Review plugins for cleanup and uninstall behavior before installing them. Prefer components that document their tables, options and removal process.
  • Monitor the largest tables and autoloaded options monthly or after major plugin changes.
  • Use a persistent object cache when it fits the site architecture; it can change where transient values are stored, but it does not eliminate the need to audit other options and tables.
  • Schedule backups independently from cleanup. A recurring cleanup job without a tested restore path increases risk rather than reducing it.
  • Ask managed WordPress hosting support for staging, database export and optimization assistance if you cannot safely use WP-CLI or database tools. Capabilities and permissions vary by host, so confirm them before relying on the service.

Frequently asked questions

Can I delete every revision?

Only if your editorial workflow does not require rollback and you have a verified backup. Most sites should retain a deliberate amount of history and set a finite future limit.

Will deleting transients break plugins?

Expired transients are temporary cache values and active code can recreate them, so deletion normally causes a cache miss rather than permanent loss. Delete only expired entries and investigate any unusually large transient that immediately returns.

Does table optimization choose safe data?

No. Optimization reorganizes or attempts to reclaim table storage. It does not understand WordPress revisions, comments, transients or plugin ownership.

Why did the database file barely shrink after cleanup?

Deleted rows may leave reusable free space inside a table, indexes can remain large, and the storage engine may not return space to the operating system. Compare table statistics and query behavior, then run optimization when appropriate.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Is 800 KB an absolute autoload limit?

No. It is WordPress’s general guideline for keeping autoloaded options under approximately 800 KB. Treat it as an investigation threshold, not a promise that every site above or below it will perform a particular way.

Frequently Asked Questions

How often should I clean a WordPress database?

Measure monthly and after major plugin changes; schedule deletion only for records whose ownership and retention rules are understood.

What is the safest first cleanup?

Back up the database and files, then remove clearly reviewed post or comment trash and expired transients on staging before touching plugin-owned data or autoloaded options.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

backupsDatabase Optimizationwebsite maintenanceWordPressWP-CLI

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.