Skip to main content
pg_ttl_index

pg_ttl_index

Automatic Time-To-Live (TTL) data expiration for PostgreSQL

High-performance PostgreSQL extension for automatic data expiration with batch deletion, auto-indexing, and built-in statistics tracking.

PostgreSQL 12+Production Readyv2.0.0
Quick Example
-- Start background worker
SELECT ttl_start_worker();

-- Create table
CREATE TABLE sessions (
  id SERIAL PRIMARY KEY,
  data JSONB,
  created_at TIMESTAMPTZ 
    DEFAULT NOW()
);

-- Auto-expire after 1 hour
SELECT ttl_create_index(
  'sessions', 
  'created_at', 
  3600
);

-- That's it! ✨

Why pg_ttl_index?

Everything you need for automatic data expiration in PostgreSQL

🔄

Automatic Data Expiration

Set TTL rules once and let the background worker handle everything. No manual queries, no cron jobs - just automatic, reliable cleanup.

High Performance

Batch deletion handles millions of rows efficiently. Auto-created indexes ensure fast cleanup. Advisory locks prevent overlapping runs.

📊

Built-in Monitoring

Track deletion statistics, monitor worker health, and view cleanup history with dedicated SQL views. Production-ready observability out of the box.

🔒

ACID Compliant

Per-table error handling ensures one failure doesn't affect others. Safe, transactional cleanup that never compromises data integrity.

🎯

Zero Configuration

Smart defaults work for most use cases. Auto-indexing, optimal batch sizes, and intelligent cleanup intervals require no tuning to get started.

🗂️

Multiple Tables

Configure different expiration times for different tables. Sessions expire in minutes, logs in days, audit trails in months - all managed automatically.

10K+
Rows/Second
0
Manual Scripts
100%
Automatic

Ready to automate your data cleanup?

Install pg_ttl_index in minutes and never worry about expired data again.