Skip to content
  • Home
  • About
  • No Access
  • Privacy Policy
Bits of .NET
Bits of .NET
  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio

Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

  • C#
  • Asp.Net Core
  • SQL
  • Windows
  • WordPress
  • AI
  • JavaScript
  • CSS
  • MORE
    • HTML
    • Ajax
    • Git
    • Docker
    • Kubernetes
    • Photoshop
    • Visual Studio
Wordpress

WordPress: Fix Post Revisions Bloating the Database After Autosave

- 01.12.26 - ErcanOPAK

📝 Fix Post Revisions Bloating the Database After Autosave

WordPress autosaves the post being edited roughly every 60 seconds by default and, depending on how WP_POST_REVISIONS is configured, can keep every one of those autosaves as a separate row in wp_posts indefinitely — a long editing session on a single post can quietly generate dozens of revision rows, and across a few hundred posts that adds up to a wp_posts table that’s mostly revision history rather than actual content, slowing down any query that scans the whole table.

🔎 The Problem

SELECT post_type, COUNT(*) FROM wp_posts GROUP BY post_type;
-- post_type = 'revision'   : 48,212 rows
-- post_type = 'post'       :     312 rows
-- revisions outnumber actual posts more than 150 to 1

✅ Fix: Cap Revisions Going Forward, Then Clean Up the Backlog

  • Add define('WP_POST_REVISIONS', 10); (or whatever number fits your editorial workflow) to wp-config.php so future autosaves stop accumulating without limit per post.
  • Run a one-time cleanup query (or a well-reviewed plugin) to delete revision rows beyond your new cap for posts that already have hundreds, rather than only fixing the setting going forward and leaving the existing bloat untouched.
  • Schedule a periodic cleanup (WP-Cron or a server cron job) if the site has frequent long editing sessions, so the revision count stays bounded automatically instead of needing another manual cleanup later.

🚨 Why This Is Dangerous

  • Always back up the database before running a bulk revision-delete query — a too-broad WHERE clause on wp_posts can take real content down with the revisions if it’s not scoped carefully.

Autosave is saving your work exactly as often as you asked it to — the database bloat is a sign nothing was ever told to clean up after it.

— WordPress Admin

Related posts:

WordPress: Fix an XML Sitemap That Is Missing Pages You Know Are Published

WordPress: Fix an XML Sitemap That Is Missing Pages You Know Are Published

Wordpress: Dequeueing Unused CSS/JS from Plugins to Improve LCP

WordPress: Dequeueing Unused CSS/JS from Plugins to Improve LCP

Wordpress: Fix Media Library Thumbnails Breaking After a CDN Switch

WordPress: Fix Media Library Thumbnails Breaking After a CDN Switch

Views: 0
Found this useful? Share it
XLinkedInWhatsApp

Post navigation

Windows 11: Fix Share Window Forgetting Recent Contacts
Visual Studio: Fix the Call Stack Window Losing Local Variables

Leave a Reply Cancel reply

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

Most Read

  1. 01How to make theater mode the default for Youtube 1,079 views
  2. 02How to add default value for Entity Framework migrations for DateTime and Bool 997 views
  3. 03Get the User Name and Domain Name from an Email Address in SQL 996 views
  4. 04Get the First and Last Word from a String or Sentence in SQL 873 views
  5. 05How to select distinct rows in a datatable in C# 868 views
  6. 06How to enable, disable and check if Service Broker is enabled on a database in SQL Server 671 views
  7. 07Add Constraint to SQL Table to ensure email contains @ 631 views
  8. 08Average of all values in a column that are not zero in SQL 584 views
  9. 09How to use Map Mode for Vertical Scroll Mode in Visual Studio 561 views
Bits of .NET

Daily micro-tips for C#, SQL, performance, and scalable backend engineering.

Social

  • ErcanOPAK.com
  • GoodReads
  • LetterBoxD
  • Linkedin
  • The Blog
  • Twitter
Back to top
© 2026 Bits of .NET | Built with Xblog Plus free WordPress theme by wpthemespace.com