Skip to content

pg_data_retention

PostgreSQL background-worker extension that applies table data retention policies.

pg_data_retention · PostgreSQL background-worker extension that applies table data retention policies.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
100864pg_data_retentionpg_data_retention0.0.0ADMINMITRust

PostgreSQL · 13, 14, 15, 16, 17, 18

Usage

Sources:

pg_data_retention is a version 0.0.0 background-worker experiment that deletes rows according to entries in public.data_retention_policy. It must be present in shared_preload_libraries, followed by a server restart.

CREATE EXTENSION pg_data_retention;
SELECT *
FROM public.data_retention_policy
ORDER BY database_name, schema_name, table_name;

Destructive Prototype Warning

At startup, current source connects to the postgres database, drops public.data_retention_policy if it exists, and recreates it. The orchestrator wakes every ten seconds, launches deletion workers sequentially, and panics on an SQL failure. The documented cron_schedule field is not implemented, and the repository explicitly lists missing worker and cross-version tests.

Do not preload this code on a server containing valuable data. Rebuilding the policy table destroys configuration, and a mistaken table, timestamp column, retention period, or batch size can delete application rows. Treat the source only as a prototype to audit and redesign in an isolated environment.

Table reader