Database Maintenance for WordPress: What You Need to Know

The WordPress database is the part of your site nobody looks at until it is slow. Here is what is in it, how it grows, and how to keep it lean.

Network and database wires representing WordPress database maintenance

Every WordPress site has a database sitting behind it, and almost no one ever looks at it. The database holds your posts, pages, users, settings, comments, and the working data for every plugin you have ever installed. It grows quietly over time, and most of the data in an older WordPress database is not the actual content but the accumulated dust of years of plugin churn, revisions, and abandoned options.

Database maintenance is not glamorous, but it makes a meaningful difference to site speed, backup size, and the simplicity of recovery if something goes wrong. This article explains what is in a WordPress database, why it grows, and how to clean it up without breaking the site.

The core tables

A standard WordPress install has around a dozen core tables. The most important to know are wp_posts, which holds all post and page content, wp_postmeta, which holds metadata associated with those posts, wp_options, which holds site wide settings and a lot of plugin data, wp_users and wp_usermeta, which hold accounts and their metadata, wp_terms and wp_term_relationships, which handle categories and tags, and wp_comments and wp_commentmeta for comments.

Plugins commonly create their own tables too. SEO plugins, security plugins, form builders, ecommerce platforms, and analytics tools often add several tables of their own. A well used WooCommerce site can have 40 or 50 tables on top of the WordPress core set.

What makes a database grow

Several common patterns cause WordPress databases to balloon out of proportion to the actual content on the site.

Post revisions. WordPress saves a new revision every time you edit a post. By default, this is unlimited. A page that has been worked on over years can have hundreds of revisions, each one stored in full in wp_posts.

Auto drafts. WordPress periodically auto saves your work. Old auto drafts that were never cleaned up can accumulate.

Transients. Plugins use the WordPress transient API to cache short lived data. When the cache expires, the entry is not always removed promptly. Expired transients accumulate in wp_options and can grow into tens of thousands of rows.

Orphaned metadata. When a post is deleted, its associated rows in wp_postmeta are not always cleaned up. Same for users and comments.

Action scheduler logs. Plugins like WooCommerce use Action Scheduler for background tasks. Each run is logged, and the logs grow rapidly. On a busy store, the logs table can have hundreds of thousands of rows.

Spam and trashed comments. Even with good filtering, unfiltered comment tables can grow large.

Uninstalled plugin debris. Many plugins do not remove their tables and options when uninstalled. A site that has tried fifty plugins over its life may still have data from forty of them sitting in the database.

Why this matters

A bloated database does not always cause obvious problems, but it makes everything slightly slower. Page loads spend more time waiting on database queries. Admin pages take longer to render. Backups grow larger and take longer to complete. Restores from backup take longer too, which matters during recovery.

A clean database is faster, smaller, and easier to work with. The improvement is rarely dramatic on its own, but combined with other maintenance it contributes to a site that stays responsive.

Safe database maintenance

Before doing any database work, take a verified backup. Database cleanup is the kind of operation that is fast and safe most of the time and disastrous the rest. The cost of a backup is fifteen minutes. The cost of not having one is potentially the whole site.

Once a backup is in hand, the cleanup tasks worth doing in order are these.

Limit post revisions in wp-config.php. Setting WP_POST_REVISIONS to a small number caps how many revisions WordPress keeps per post. Five is a reasonable default.

Empty trash for posts, comments, and any custom post types. Most cleanup plugins handle this safely.

Delete expired transients. WordPress has a built in function for this. Some optimisation plugins expose it as a one click action.

Drop tables from plugins that have been uninstalled. This requires care. Confirm the table is no longer used by any active plugin before dropping.

Trim action scheduler logs if you are using WooCommerce or any plugin that relies on the Action Scheduler. Recent versions of Action Scheduler self prune by default, but on older installs this needs manual attention.

Reindex tables. Over time, indexes can become fragmented. A reindex tightens them up and speeds up queries.

Tools that help

Several plugins are widely used for database cleanup. WP Optimize, Advanced Database Cleaner, and the database tools inside Perfmatters are common choices. Each provides a checklist of cleanup actions you can review before applying. Avoid plugins that aggressively delete data without showing you what they intend to remove.

For larger sites, the right answer is often direct database work with phpMyAdmin, Adminer, or the wp cli command line tool. This requires more care but gives more control.

How often to run database maintenance

Quarterly is a reasonable cadence for most business sites. Monthly is sensible for high traffic ecommerce. After any major plugin migration or content cleanup, an extra round is worth doing. The smaller the database stays, the easier every backup, restore, and audit becomes.

Need a hand?

If you would like Smart Coding to audit your WordPress database, identify the bloat, and run a careful cleanup with a backup safety net, get in touch. It is a quiet improvement that compounds across every other piece of maintenance you do.

Claire Smith Avatar
Sponsored Loved this story? Defyn turns articles like this into the websites your competitors wish they had. Talk to us → defyn.com.au