> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getcollate.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Retention Application

> Automate cleanup of outdated internal records and orphaned data in Collate with the Data Retention Application to maintain long-term database performance.

# Data Retention Application

The **Data Retention** application in **Collate** automates the cleanup of the internal database to maintain long-term performance and prevent data bloat. It provides administrators with an efficient mechanism to define retention policies for event-related records, ensuring scalability and compliance with data management practices.

## Overview

As **Collate** processes events related to metadata changes and pipeline executions, it stores these events in internal tables. Over time, these tables can grow significantly and affect system performance. The **Data Retention** application enables automated and scheduled cleanup of outdated records.

Beyond routine housekeeping, the app also repairs data integrity issues that build up over time. When a parent entity (for example, a database or a test suite) is deleted, some child records can be left behind without a valid reference back to a live entity. This includes relationships, tags, and test cases. The Data Retention application finds and removes this orphaned, stale data so it doesn't accumulate or surface in search and lineage.

### Key Features

* Automated cleanup of outdated internal records.
* Removes orphaned relationships, tags, and test cases left behind when a parent entity is deleted.
* Configurable retention periods for different data categories.
* Helps maintain system performance and database efficiency.
* Supports compliance with organizational data retention policies.

## Cleanup Targets

The app deletes old or orphaned records from these key internal tables:

* **change\_event**: Stores metadata change event logs, cleaned up based on retention period.
* **entity\_relationship**: Stores relationships between entities (containment, ownership, lineage, tests). Orphaned rows removed when a parent entity is deleted.
* **tag\_usage**: Tag assignments on entities. Orphaned entries removed when the tagged entity no longer exists.
* **test\_case**: Data quality test cases. Orphaned entries removed when their parent test suite or linked entity is deleted.
* **data\_quality\_data\_time\_series**: Historical test case results, cleaned up based on retention period.
* **audit\_log\_event**: System audit log entries, cleaned up based on retention period.

## Implementation Details

* **Schedule**: Runs weekly by default.
* **Cron**: `0 0 * * 0` (every Sunday at midnight).
* **Batch Processing**: Cleans up records in batches of 10,000.
* **Triggering**: Can be executed manually or allowed to run on schedule.
* **Application Class**: `org.openmetadata.service.apps.bundles.dataRetention.DataRetention`
* **Permission Requirement**: Requires admin privileges to configure or trigger.

## Install Data Retention Application

1. Navigate to **Settings** > **Applications** and then click on **Add apps**.

2. Click **Add apps**.

   <img src="https://mintcdn.com/collatedocs/bKBGXz6FBahnppp1/public/images/ai-2.0/admin-guide/applications/select-data-retention.png?fit=max&auto=format&n=bKBGXz6FBahnppp1&q=85&s=d4bb44155c75a4958879774f57382f77" alt="Select Data Retention Application" width="2926" height="1556" data-path="public/images/ai-2.0/admin-guide/applications/select-data-retention.png" />

3. Select the **Data Retention** application and install it.

   <img src="https://mintcdn.com/collatedocs/bKBGXz6FBahnppp1/public/images/ai-2.0/admin-guide/applications/install-data-retention.png?fit=max&auto=format&n=bKBGXz6FBahnppp1&q=85&s=d34fb874569c26ca18d2e6567b5f7026" alt="Install Data Retention Application" width="2765" height="1096" data-path="public/images/ai-2.0/admin-guide/applications/install-data-retention.png" />

4. Configure the following retention periods in days:

   * **Change Event Retention Period**: The number of days to retain change event records. Default value is **7**.
   * **Activity Threads Retention Period**: The number of days to retain activity feed records. Default value is **60**.
   * **Test Case Results Retention Period**: The number of days to retain test case results. Default value is **1440**.
   * **Profile Data Retention Period**: The number of days to retain column and table profiling data. Default value is **1440**.
   * **Audit Log Retention Period**: The number of days to retain audit log entries. Default value is **90**.

   <Tip>
     **Tip**: The retention period is applied to each cleanup target based on its timestamp.
   </Tip>

   <img src="https://mintcdn.com/collatedocs/bKBGXz6FBahnppp1/public/images/ai-2.0/admin-guide/applications/configure-data-retention.png?fit=max&auto=format&n=bKBGXz6FBahnppp1&q=85&s=3cef08df389f288f4622e512903be875" width="1970" height="1018" data-path="public/images/ai-2.0/admin-guide/applications/configure-data-retention.png" />

5. Schedule or select **On Demand** to run the application manually.

   <img src="https://mintcdn.com/collatedocs/bKBGXz6FBahnppp1/public/images/ai-2.0/admin-guide/applications/scedule-data-retention.png?fit=max&auto=format&n=bKBGXz6FBahnppp1&q=85&s=69a3e8a3bffcf801fc25d88a34b98ff0" alt="scheduling" width="2749" height="842" data-path="public/images/ai-2.0/admin-guide/applications/scedule-data-retention.png" />
