
Over time, every WordPress site tends to accumulate useless data: revisions, temporary options, orphaned tables. This makes the database heavier and slows down page loading and operations in the back end.
Optimising the database means slimming it down, freeing up space and improving performance, but it has to be done carefully to avoid damage.
In this article I explain what you can do safely, even if you are not a developer.
What the WordPress database contains
The database stores everything that is not a “file”, that is:
- Content (pages, posts, custom fields)
- Users and roles
- Plugin settings
- Comments and metadata
- Cron jobs and temporary data
It is made up of tables, most of which have the wp_ prefix (or a custom one).
When a site has been live for months or years, it is normal for the database to grow. The problem starts when it contains too much useless or outdated data.
What you can optimise safely
Post revisions
Every time you edit a post or page, WordPress creates a revision. Keeping 50 saved versions of every piece of content is not useful.
You can limit them by adding this line to the wp-config.php file:
define( 'WP_POST_REVISIONS', 5 );
Or delete them in bulk with plugins such as WP-Sweep or Advanced Database Cleaner.
Expired transients
Many plugins store temporary settings called transients. If they are not removed properly, they pile up.
Plugins such as WP-Optimize or Advanced Database Cleaner let you delete them without risk.
Spam and trashed comments
Check the wp_comments table and regularly empty comments marked as spam or in the trash.
Autoloaded options
Many plugin settings are loaded on every page through the wp_options table. If too many unnecessary rows are set to autoload, the site slows down.
You can use Query Monitor or more advanced tools to see what is loaded automatically. But here it is better not to delete anything unless you know exactly what you are doing.
Orphaned tables
Uninstalling a plugin does not always remove the tables it created. Over time you may end up with unused tables taking up space.
Advanced Database Cleaner (premium version) helps you find tables that are not linked to any active plugin. Here too: delete only if you are sure.
What to avoid
- Do not delete tables by hand if you do not know what they do
- Do not use “all-in-one” plugins that run automatic actions without warning you (e.g. aggressive clean-up plugins)
- Do not do any of this on a live site without taking a backup first
How often to do it
Once every 1-3 months is enough for most brochure sites and blogs. If you run an online shop or a very active site, once a month.
Conclusion
Optimising the WordPress database helps keep your site faster, lighter and easier to manage over time. But you need to know where to work, what is safe to delete and what is not.
If your site is starting to slow down and you want a professional database clean-up, get in touch: I can analyse it and work on it safely.