Drupal - Clean Deleted Field from Database

using drush:

$ drush eval "field_purge_batch(500)"

you might have to run a few times, or increase the $batch_size then there might still be field_deleted and field_deleted_revision tables, even after running cron

query

SELECT * FROM `field_config` WHERE `deleted` = 1
SELECT * FROM `field_config_instance` WHERE `deleted` = 1

if you come up empty, you can safely delete those leftover tables


The entries in field_config and field_config_instance will probably have had a value of 1 in the deleted column.

This means they're marked for deletion, but won't actually be deleted until you run cron (deleted field data is purged in field_cron()).


As an alternative to running cron to remove deleted data, you can manually run field_purge_batch($batch_size).

To manually run the function you can either:

  • Bootstrap Drupal in a php file
  • Create a menu hook page callback
  • If you have the devel module installed visit /devel/php

The $batch_size to use will vary depending on your server environment and needs. I've used values as low a 5 and as high as 10000.

Tags:

Entities