---
title: "Clearing out expired fields in your databases - the untold wonders of Drupal Cron"
date: "2023-08-16T22:20:08+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/93411-clearing-out-expired-fields-your-databases-untold-wonders-drupal-cron"
id: "719d9bbc-5c62-4478-b506-babc3148a2ed"
---

Table of contents will be added

**Issue**
---------

A database table, such as the `key_value_expire` table, is filled with expired entries. Large tables with outdated information can cause maintenance and performance issues, and even service interruptions. 

**Resolution**
--------------

The fix is to purge all of the entries which have an expire date that has already passed. Running your site's Drupal Cron regularly does this. 

Looking at D.O's [Cron automated tasks overview](https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-tasks/cron-automated-tasks-overview) you will see that there are four bullet points regarding tasks that a properly configured cron job can manage:

*   Updates the index of site content used by the [Search](https://www.drupal.org/docs/8/core/modules/search) module.
*   Queues feeds to be updated by the [Aggregator](https://www.drupal.org/docs/8/core/modules/aggregator) module.
*   Checks for available updates for the [Update Manager](https://www.drupal.org/docs/8/core/modules/update) module.
*   Performs routine maintenance tasks, such as removing older rows from logs, for the [System](https://www.drupal.org/docs/8/core/modules/system) module.

Looking deeper into `core/modules/system/system.module`, you can see:

    function system_cron() {
      // Clean up the flood.
      \Drupal::flood()->garbageCollection();
    
      foreach (Cache::getBins() as $cache_backend) {
        $cache_backend->garbageCollection();
      }
    
      // Clean up the expirable key value database store.
      if (\Drupal::service('keyvalue.expirable.database') instanceof KeyValueDatabaseExpirableFactory) {
        \Drupal::service('keyvalue.expirable.database')->garbageCollection();
      }

For additional reference you can also see:

*   [https://api.drupal.org/api/drupal/8.9.x/search/garbageCollection](https://api.drupal.org/api/drupal/8.9.x/search/garbageCollection)
*   [https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21KeyValueStore%21KeyValueDatabaseExpirableFactory.php/function/KeyValueDatabaseExpirableFactory%3A%3AgarbageCollection/8.9.x](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21KeyValueStore%21KeyValueDatabaseExpirableFactory.php/function/KeyValueDatabaseExpirableFactory%3A%3AgarbageCollection/8.9.x)

**Cause** 
----------

Disabling Drupal Cron for a prolonged period of time.