I have a drupal 7 sites, where it keeps node and field revisions. I keep revisions for the case where by mistake a new faulty version is saved and I want to revert back.

But, now I want to clean and optimize the database so to take less space in hard disk.

What are some methods of deleting all the revisions except the current one, for all nodes/fields of the site?


Use the Node Revision Delete module to delete and manage your revisions. (I am the maintainer of the module.)

The Node Revision Delete module allows you to manage the revisions of the Node according to your choice. It helps you to keep the specific number of revisions for the node. This module provides you the flexibility for applying the revision delete for the specific content type and run it on the specific time. You can manage your settings from the Node Revision Delete Administration Page.


There's not yet a stable release for Revision deletion but a D7 port is on its way (not sure if its functional at all).

In this thread someone suggested using VBO to isolate revisions and delete them.

If you feel comfortable with the API, make a loop through all your nodes, retrieves the revisions using node_revision_list() and delete them using node_revision_delete().

As a last resort and if you like messing with the DB (like I do) you can delete revisions' rows in field_revision_* and node_revision tables. Try this:

WARNING: not tested at all !

DELETE FROM field_revision_body
  FROM node
  WHERE vid = revision_id

DELETE FROM node_revision
  FROM node
  WHERE node.vid = node_revision.vid

You can find the complete list of your revisions' tables in the information_schema database:

WHERE TABLE_NAME LIKE 'field_revision%'
AND TABLE_SCHEMA = 'your_database';
  • 3
    Node Revision Delete module now has a stable release. – Free Radical May 13 '14 at 10:14
  • Testing this, I believe the condition on node_revision query should be WHERE node.vid = node_revision.vid. Errors as is. Perhaps specify the tables on the field_revision_body query as well? – digitgopher Jan 6 '16 at 18:51
  • The Revision Deletion module mentioned in this answer recommends using Node Revision Delete instead, since we don't need 5 modules doing the same thing. See accepted answer. – mbomb007 Jul 3 at 16:50

In same situation I used code below:

foreach (node_load_multiple($nids) as $node) {
  // Delete sub revisions.
  foreach (node_revision_list($node) as $vid => $revision) {
  // Delete archived revisions.

I made this for the VBO folks (execute arbitrary PHP), it will delete all revisions (except current). This relies on the sort order built into node_revision_list(), so back up your DB & test for desired results before using on live data.


  $revision_array = node_revision_list($entity);  
  $revision_array_ASC = array_reverse($revision_array, TRUE);

  foreach ($revision_array_ASC as $vid => $node) {
    $count = count($revision_array_ASC);
    if ($count > 1) {

  $revision_array = node_revision_list($entity);  
  • Seems like you are having a big trouble to avoid deleting the current revision (sort, count). But node_revision_delete already prevents deleting the current revision. – dxvargas Apr 17 '15 at 8:47

Node Revision Delete module now has a stable release.

The Node Revision Delete module lets you to track and prune old revisions of content types. Features:

  • Define the max amount of revisions to keep per content type.
  • Run on Drush, cron run or on a different period (daily, weekly, etc).

protected by kiamlaluno Mar 28 at 17:16

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.