How-To4 min read

WordPress Database Cleanup: What Is Safe to Remove?

WordPress database cleanup, done safely: what causes database bloat, which tables you can trim, and the backup to take before you touch wp_options.

By Matthew Zhao · Editor, Hosted EZ


WordPress database cleanup is routine maintenance, not a rebuild, as long as you work in the right order. Post revisions, expired transients, and tables left behind by deleted plugins pile up quietly until backups crawl and queries drag. This guide covers what is safe to remove, what to leave alone, and the copy you keep before deleting anything.

This guide focuses on the checks a small-site owner can make safely, and points out where a host or developer should take over. Read how to choose a web host if you are still picking a provider, and how to migrate hosting without downtime before moving a site wholesale.

Back up before any WordPress database cleanup

Export a full copy of the database before you delete a single row. Then remove one category of data at a time — revisions first, for example — and load both the public site and the admin area. A page that looks fine while logged out can still fail for an editor.

Make a short note of the table names you touched, the row counts before and after, and the time. Do not put passwords in the note. You want enough detail to retrace the work without creating a new security risk.

Where database bloat comes from

Most database bloat is WordPress doing its job too enthusiastically: a revision saved on every edit, transients that were supposed to expire, and comment spam. The rest is plugins — many leave their tables behind on uninstall, and some write autoloaded rows into wp_options that load on every single request.

Use a staging copy for cleanup that touches an active store or membership site. A staging site is not a luxury when the rollback is faster than explaining a broken production database.

Test the result like a visitor

Check the error log before and after cleanup rather than judging by feel. If a plugin breaks because its table went missing, the log names it long before a customer does.

Test the normal path first, then the part with the most consequence. For a store, that is checkout. For a membership site, it is logging in. A test should answer one question rather than produce a vague impression.

When to stop and ask for help

Stop when the next action could overwrite data you cannot restore. Send support the domain, the time in UTC, the exact table or plugin involved, and the changes you made. Include a screenshot when it shows the error, but never include passwords or full payment information.

The database is one of the few pieces of hosting WordPress documents formally: WordPress's server requirements covers the supported MySQL and MariaDB versions. Use it to understand the terms, then return to the small, reversible next step.

A sensible maintenance habit

Put WordPress database cleanup on a schedule rather than treating it as an emergency. Quarterly is enough for most small sites — revisions and transients grow back. A plugin can optimize the WordPress database for you, or your host's phpMyAdmin can do it by hand; either way, take the backup first.

If the site is still slow after a clean database, the problem is usually elsewhere. Start with database performance basics before buying a bigger plan.

Keep the change auditable

Use a short before-and-after record. Write the table you touched, the row count you found, the exact time you changed it, and the result of the test. This record is useful even when everything works. A few months later, it tells you why a wp_options row is gone or a table is smaller than a plugin expects.

Do not confuse the admin dashboard with evidence from the live site. The dashboard can report a smaller database while a cached page hides a broken widget. Test from a private browser window, where a cached answer cannot mislead you.

If you hand the task to someone else, give them the record rather than a conclusion. "The site is slow" is hard to investigate. "Queries slowed after this plugin was removed, and its table is gone" gives the next person a useful starting point.

One last check

Before you call the cleanup finished, load the site the way a visitor would: search, a form, checkout if you have one. If something behaves differently, note the difference and keep troubleshooting from that point. A quiet confirmation now is much easier than discovering a missing table during a launch.

Leave a useful handoff

Save the final result — what was removed, the size before and after, the date — alongside the export you took first. If someone revisits the database next year, they should be able to see what changed without reconstructing the work from browser history.

Bottom line

WordPress database cleanup gets easier when you export first, remove one category of data at a time, and test where it matters. The clutter grows back on its own schedule, so put cleanup on yours — and keep the export until the site has run quietly for a while.

Frequently asked questions

Should I clean the whole WordPress database at once?

No. Remove one category of data at a time — revisions, then transients, then orphaned tables — and test between each step. Keep the export until you know the result is stable.

What information should I give hosting support?

Give the domain, the table or plugin involved, UTC time, error text, and steps already tried. That is usually enough for support to find the relevant logs.

Should I keep a backup before cleaning the database?

Yes. Export the database and verify the file before deleting anything. Restoring a table is trivial when you have the export and impossible when you do not.

About the author

Matthew Zhao

Matthew has spent his career running production server fleets — tens of thousands of machines' worth. He writes about hosting the way he wishes someone had explained it to him: plainly.

About Hosted EZ →

Get the next guide in your inbox

One email when we publish something worth your time. No spam, unsubscribe whenever.

Keep reading