WP Speed Tip #6 – Limit Post Revisions to Prevent Database Bloat

Why It Matters

Every time you hit “Save Draft” or “Update,” WordPress stores a new revision in the database.
One post edited 20 times = 20+ stored versions.

Multiply that by 50+ posts/pages and you’ve bloated your database with junk you’ll never use.
This slows down:

  • Admin panel queries
  • Backup times
  • Database-heavy plugins like search and reporting

The Fix: Limit Revisions in wp-config.php

Add this line to your wp-config.php (above the line that says That’s all, stop editing!):

define('WP_POST_REVISIONS', 3);

This tells WordPress: “Keep only the latest 3 revisions of each post — delete the rest.”

You can also set it to:

  • false → disables revisions entirely (not recommended unless you’re disciplined)
  • 5 → keeps 5 versions, etc.

Optional Cleanup (One-Time)

To delete existing old revisions, run this SQL in phpMyAdmin or via WP-CLI:

DELETE FROM wp_posts WHERE post_type = "revision";

Backup before doing this. Do not run if you’re unsure about direct DB access.


Bonus Tip:

Use the Code Snippets plugin if you don’t want to touch wp-config.php, but setting it directly is cleaner.

What It Actually Does

  • Reduces size of the wp_posts table (often the biggest one)
  • Speeds up queries when editing or loading content-heavy pages
  • Keeps your backup files smaller and faster to restore

Bookmark this tip. Coming up next:
Tip #7 – Self-Host Fonts to Eliminate External Requests

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *