In this guide: How to clean up a slow WordPress database: why databases get bloated, backing up first, removing revisions and spam, optimizing tables, and automating cleanup.
Every WordPress site stores its content, settings, and activity in a database. Over time, that database collects clutter: hundreds of post revisions, spam comments, expired temporary data, and leftover tables from plugins you deleted years ago. A bloated database can slow down your admin area and dynamic pages.
Here’s how to clean it safely.
Common sources of database clutter:
wp_options table loaded on every page request. Too much autoloaded data slows every page.Always back up your database before cleaning. Deleting data is permanent.
See Website Backups: The 3-2-1 Rule Explained.
The easiest method is a cleanup plugin such as WP-Optimize, Advanced Database Cleaner, or the database tools in LiteSpeed Cache or WP Rocket.
Typical cleanup tasks:
Limit future revisions by adding this line to wp-config.php:
define( 'WP_POST_REVISIONS', 5 );
This keeps the five most recent revisions per post — enough for safety, without endless buildup.
Leftover plugin tables: tools like Advanced Database Cleaner can identify tables and options not used by active plugins. Be careful — only delete data you’re sure belongs to removed plugins.
Large log tables: configure logging plugins to keep only 30–90 days of data, or disable logs you don’t use.
After deleting data, database tables may still hold unused space. Optimizing reorganizes tables and reclaims that space.
Check autoloaded data:
The wp_options table can slow your site if it contains too much autoloaded data. Some cleanup plugins and Site Health tools show autoloaded data size. Large autoloaded entries from deleted plugins can often be removed or set to not autoload — carefully.
Use object caching: for busy sites, Redis or Memcached reduces repeated database queries — ask your host.
Check the database engine: modern WordPress tables should use InnoDB, not the old MyISAM engine. Your host can help convert.
Set it and forget it:
WP_POST_REVISIONS limited.EMPTY_TRASH_DAYS).What not to do:
Further reading: official WordPress documentation
We may earn a commission on purchases made through these links, at no extra cost to you.
Don’t miss the chance to participate in the biggest giveaway of this year.