WordPress

Revision

Revision is a saved earlier version of a post or page that WordPress keeps each time you click Update. Revisions let you compare and restore, and they also add rows to your database.

How it is measured

Each revision is a row in wp_posts with post_type revision and post_parent set to the original post's ID. It holds a full copy of the title, content, and excerpt. By default WordPress keeps an unlimited number; WP_POST_REVISIONS in wp-config.php caps it, for example define( 'WP_POST_REVISIONS', 5 ).

Count them with SELECT COUNT(*) FROM wp_posts WHERE post_type = 'revision', or with wp post list --post_type=revision --format=count. The post editor's Revisions panel shows a slider and a diff.

Worked example

A recipe site has 1,100 posts and 41,000 revision rows. The most-edited post, a sourdough guide of 6,000 words, has 212 revisions of about 40 KB each, around 8.5 MB for one article. wp_posts is 380 MB and every backup carries it.

The owner sets the limit to 10, deletes all but the latest 10 per post using WP-CLI after a backup, and the table drops to 140 MB.

How it differs

A revision is a snapshot created on a manual save, while an autosave is a single rolling copy made on a timer. Revisions are a history, and autosave is crash protection. Neither one is a WordPress backup, since both live in the same database as the original post.

Common errors

Deleting all revisions with no backup. Setting WP_POST_REVISIONS to false and losing the ability to roll back. Expecting custom fields to be restored with the content. Counting the revision rows as posts in a report. Restoring an old revision and overwriting a newer edit by a colleague.

In practice

Count revisions this week. If the number is many times your post count, set a cap of 10 to 20, take a database backup, and prune the old ones. Tell editors that Restore replaces the current content.

See also

Autosave, WordPress

Sources

Count this on a real site.

Watch my website