HomeMethod

Knowledge

Web VitalsTechniquesSnippetsAnswersImpactsBottlenecks

Limit post revisions

  • Performance

Every time you hit Save or Update, WordPress creates a complete copy of the post in the database. Over time, a site with 500 posts can easily accumulate 10,000+ revision rows that bloat the database and slow down queries.

limit-revisions.php
<?php
/**
 * Limit Post Revisions
 *
 * WordPress stores every save as a revision, which bloats the database over
 * time. A site with 500 posts and unlimited revisions can easily have 10,000+
 * revision rows. This limits revisions to a sensible number — enough to
 * recover from mistakes, few enough to keep the database lean.
 *
 * Usage: Add to wp-config.php, above the "That's all, stop editing!" line.
 *        Set to 0 to disable revisions entirely, or any positive integer.
 *
 * @category performance
 * @language php

 *
 * @author Adame Dahmani https://adame.io
 * @support Support my family project: https://adame.io/fundraiser
 */
define( 'WP_POST_REVISIONS', 5 );

Five revisions is enough to recover from most mistakes. Set it to 0 to disable revisions entirely, though that’s risky if multiple people edit content.

Support our family now