I have a Drupal 7.24 Website making heavy use of field collections.

The field_collection_item_revision keeps getting bigger and bigger (9'000'000 rows) and only 200'000 entries are in field_collection_item.

What is the most secure and efficient way to "clean" this table?

PS: A SQL request with nested selects is not an option, it's too slow.

1 Answer 1


(Assuming a MySQL database)

Execute the following MySQL request:

DELETE fcir FROM field_collection_item_revision AS fcir
  RIGHT JOIN field_collection_item AS fci 
    ON fcir.item_id = fci.item_id
  WHERE NOT fcir.revision_id = fci.revision_id;

We delete all revisions that are not present in the field_collection_item table under "revision_id".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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