Is Your WordPress Database Making Your Site Slow?
Every WordPress page requires multiple database queries. Over time, the database fills with revisions, spam, and expired data. Here is what that costs and how to clean it.
Yes, a bloated WordPress database slows your site down. Every page visit starts with a round of database questions, and a database full of revisions, expired data, and plugin leftovers answers those questions more slowly. Here is how the problem builds up, how to clean it, and why this is maintenance you will need to repeat.
How does the WordPress database work?
WordPress stores almost everything in a database: your pages, posts, menus, settings, user information, comments, and plugin data. When someone visits your site, the server runs code that queries the database to get all of that information, assembles the page, and sends it.
A typical homepage visit might trigger 20 to 50 individual database queries before a single word appears on screen. A complex page with many widgets, related posts, and plugin features can trigger well over 100 queries.
Each query takes time. A fast, well-maintained database answers them in milliseconds. A slow, bloated one takes longer. That extra time stacks with everything else your server is doing.
What fills the database up over time?
Post revisions. By default, WordPress saves a copy of your content every few minutes while you are editing, and every time you publish an update. Edit a page 50 times and there are 50 copies stored. Edit 100 pages and you have thousands of revision rows. These are rarely needed and never displayed to visitors.
Spam comments. WordPress stores spam comments that were caught by your anti-spam plugin. They sit in the database indefinitely unless you actively empty the spam folder.
Expired transients. Transients are temporary data stored by plugins, like cached API responses or stored calculations. When they expire, the data stays in the database as waste unless something cleans it out.
Orphaned post metadata. When you delete a post or page, the associated metadata rows sometimes stay behind. The same happens with some plugin settings when the plugin is deleted without a proper cleanup.
Plugin tables. When you install and then delete a plugin, it often leaves its database tables behind. These unused tables add size and can slow certain database operations.
How to clean your database
Back it up first. Before any database cleanup, create a backup. Your hosting control panel almost certainly has a backup tool. A database backup takes less than a minute and means a mistake is recoverable.
Use a cleanup plugin you already have. If you have WP-Optimize, Advanced Database Cleaner, or Jetpack installed, those include database cleaning tools. Use what is already there rather than adding another plugin for this purpose.
Use phpMyAdmin if you are comfortable with it. Your hosting control panel includes phpMyAdmin, a database management tool. You can run cleanup queries directly there. Common tasks are removing post revisions, clearing expired transients, and emptying spam comments. Your hosting provider likely has documentation with the specific queries.
Limit revisions going forward. Adding a single line to your wp-config.php file limits how many revisions WordPress keeps per post. Setting it to 3 or 5 means the database does not grow as fast. This is a one-time change with ongoing benefit.
What you can do today
- Empty your spam folder. Log into WordPress, go to Comments, Spam, and click Empty Spam. This takes 30 seconds and can remove thousands of rows.
- Empty your trash. Go to Posts, look for Trash, and empty it. Trashed posts still exist in the database.
- Run a database cleanup. If you have a cleanup plugin installed, run it. Select revisions, transients, and orphaned data.
- Check how many post revisions you are keeping. There is no reason to keep 50 old versions of a page. Setting a limit of 3 to 5 is reasonable for most sites.
- Test your speed before and after. Run your address through Google PageSpeed Insights, clean the database, and run it again. On older sites, the improvement in server response time is visible.
Why this is ongoing maintenance, not a one-time fix
Database cleanup is not a problem you solve once. Revisions accumulate every time you edit content. Spam arrives daily. Plugins add transients constantly. A database you cleaned last month is already growing again.
This is the maintenance reality for WordPress. Not a reason to stop using it, but a real cost that deserves to be counted. The true cost of WordPress maintenance is worth reading if you want to understand what all of this adds up to over time.
For owners who no longer want to tend a database, Basalt moves small business websites off WordPress to a platform with nothing to hack and nothing to update. The move is free. On the new platform, there is no database queries per page, no revisions to clean, and no transients to expire.
Find out what is wrong in 60 seconds
Or skip all this. Enter your web address and we will tell you exactly what is wrong with your site. Free, 60 seconds, no account needed.
Quick answers
How does the WordPress database affect site speed?
Every page visit triggers multiple database queries. WordPress asks the database for the page content, the menu items, the widget data, the user session, and more. A larger, messier database answers these queries more slowly.
What fills up the WordPress database over time?
Post revisions (saved automatically every time you edit), spam comments, expired transient data from plugins, orphaned post metadata, trashed posts you forgot to empty, and tables left behind by deleted plugins all accumulate. A site a few years old often has tens of thousands of rows of this data.
How do I clean my WordPress database?
Several free tools help. If you have a cleanup plugin like WP-Optimize or Advanced Database Cleaner installed, use those. You can also access your database through phpMyAdmin in your hosting control panel and run cleanup queries directly. Always back up the database before cleaning.
Will cleaning the database make a noticeable speed difference?
Often yes, especially on older sites. A database with 50,000 post revision rows versus 5,000 answers queries noticeably faster. On a newer site or one that has been maintained, the difference is smaller. The biggest gains come from sites that have never been cleaned.
Sixty seconds. Zero jargon.
See what's actually wrong with your site: speed, plugins, and every way in.
Check my site free