pg_ttl_index
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_ttl_index | 3.0.0 | FEAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2730 | pg_ttl_index | No | Yes | Yes | Yes | No | Yes | - |
pg 14 breaks; rm README from RPM/DEB
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 3.0.0 | 1817161514 | pg_ttl_index | - |
| RPM | PIGSTY | 3.0.0 | 1817161514 | pg_ttl_index_$v | - |
| DEB | PIGSTY | 3.0.0 | 1817161514 | postgresql-$v-ttl-index | - |
Build
You can build the RPM / DEB packages for pg_ttl_index using pig build:
Install
You can install pg_ttl_index directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
pg_ttl_index provides automatic data expiration by associating a TTL (time-to-live) with a timestamp column. A background worker periodically deletes rows whose timestamp exceeds the configured expiration interval.
Quick Start
Functions
| Function | Description |
|---|---|
ttl_start_worker() | Start the background worker for automatic cleanup |
ttl_worker_status() | Check if the worker is running |
ttl_runner() | Manually trigger cleanup |
ttl_create_index(table, column, expire_seconds [, batch_size]) | Configure TTL expiration |
ttl_drop_index(table, column) | Remove TTL configuration |
ttl_summary() | List all TTL indexes with stats |
Examples
Session management with 24-hour expiry:
Log retention for 7 days:
Cache entries with custom expiry column (0 means the column itself holds the absolute expiry time):
Monitoring
Pause cleanup for a specific table:
Configuration
| Parameter | Description | Default |
|---|---|---|
pg_ttl_index.naptime | Cleanup interval in seconds | 60 |
pg_ttl_index.enabled | Enable/disable worker globally | on |
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)