A WordPress database never shrinks on its own. Every revision, every spam comment, every expired piece of temporary data stays until someone removes it. After a few years, a site with a few hundred pages can carry a database many times larger than it needs.
A large database is not always a slow site, but it makes backups slower, migrations harder and some queries heavier. Cleaning it up is one of the safest maintenance jobs there is, as long as you know what you are deleting.
What builds up
| Item | What it is | Safe to delete? |
|---|---|---|
| Revisions | A full copy of a page or post on every save. | Yes. Keep a few recent ones if you want to undo edits. |
| Auto-drafts | Empty drafts WordPress creates when you open “Add new”. | Yes. |
| Trashed posts and pages | Content you deleted, waiting 30 days in the trash. | Only if you are sure nothing in the trash is needed. |
| Spam and trashed comments | Comments marked as spam or deleted. | Yes. |
| Expired transients | Temporary data plugins store with an expiry date, which is not always cleaned up. | Yes. Plugins recreate what they need. |
| Orphaned metadata | Data belonging to posts or comments that no longer exist. | Yes. |
| Tables of removed plugins | Many plugins leave their tables behind when deleted. | Yes, if you are sure the plugin is gone for good. Check by table name. |
Before you clean
- Make a database backup. Cleanup is safe, but a backup costs a minute and removes all doubt. See Backups.
- Look in the trash before emptying it.
- Do it at a quiet time on large sites: the first cleanup can take a while.
Cleaning up with Keel
In Keel › Speed › Database cleanup, tick what to remove under What to remove and press Clean everything. Trashed content is not ticked by default, so nothing you might still want is removed by accident. This is in the free version.
With Keel Pro, Clean up every week repeats the same cleanup in the background every Sunday night, so the database never builds up again.
Stop it building up
- Limit revisions: in Keel › Speed › Background activity, Revisions to keep per page. Ten is plenty.
- Turn off comments on sites that do not use them: spam comments are a large share of many databases.
- Delete plugins you no longer use, rather than just deactivating them.
What not to do
- Do not delete tables you do not recognise without checking which plugin made them. Some belong to active plugins with unusual names.
- Do not “optimise” the database tables every day. It brings little after the first cleanup and locks tables while it runs.
- Do not edit the database directly in phpMyAdmin unless you know exactly what you are changing.
How much difference does it make?
On a well-kept site, little: maybe a few megabytes. On a site that has run for years with unlimited revisions, a busy comment form and a dozen removed plugins, cleaning up can shrink the database by more than half. Backups get faster, and admin screens that list posts feel lighter.
Common questions
How often should I clean the database?
After the first big cleanup, once a week or once a month keeps it small. Keel Pro can do it every Sunday night by itself.
Can cleanup delete my pages?
Only content you already put in the trash, and only if you tick it. Published pages, drafts you saved and media are never removed.
Why is my database still large after cleanup?
The biggest tables are often logs or data kept by plugins: statistics, form entries, email logs, shop sessions. Check which tables are largest in your hosting panel.