Skip to content
vabatta edited this page Mar 4, 2026 · 4 revisions

Precise, crash-safe timer scheduling for PostgreSQL.

pg_timers is a PostgreSQL extension that lets you schedule SQL statements to execute at a specific time or after a delay. It uses a background worker with wake-on-demand scheduling — no polling — so timers fire with minimal latency. All execution is transactional, subtransaction-isolated, and crash-safe via WAL. The extension is designed for native Citus compatibility through its shard_key distribution column.

Feature Highlights

  • Precision — Wake-on-demand via latch signaling; worker sleeps until the next timer is due
  • Crash-safe — WAL atomicity guarantees pending timers survive crashes and are retried on restart
  • Subtransaction isolation — One failing timer action doesn't affect others in the same batch
  • Citus-readyshard_key column enables distributed table creation out of the box
  • Simple API — Three SQL functions: schedule_at, schedule_in, cancel
  • Zero config — Works with defaults; three GUCs available for tuning

Documentation

Page Description
Getting Started Install, configure, and schedule your first timer in 5 minutes
API Reference Complete SQL function signatures, table schema, and status codes
Architecture Internals deep-dive: shared memory, background worker, tick phases
Examples Practical patterns: expiry, cleanup, notifications, Citus
Configuration GUC parameters and tuning guidance
Safety and Recovery Crash recovery, subtransaction isolation, and concurrency guarantees
Citus and Distributed Distributed usage with Citus and the shard_key column
Development Building, testing, CI, and contributing

Clone this wiki locally