PgQue installs from a single SQL file in one transaction. After installation, you need something that callsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/NikolayS/PgQue/llms.txt
Use this file to discover all available pages before exploring further.
pgque.ticker() periodically — pg_cron is the recommended default and is pre-installed (or one command away) on every major managed Postgres provider. If you do not use pg_cron, any external scheduler works instead.
Get the SQL file
Clone the repository so
\i sql/pgque.sql can resolve its relative path from the repo root.Install PgQue
Install inside a transaction so a failure leaves no half-built schema behind.Verify the install:The install creates the
pgque schema, three roles (pgque_reader, pgque_writer, pgque_admin), and all functions.Start the ticker
Choose the scheduler that matches your environment.This schedules four cron jobs: Allowed values are exact divisors of 1000 in the 1–1000 ms range. Inspect the current rate with The For sub-second ticking from an external driver, loop
With pg_cron (recommended)
pg_cron is pre-installed or one command away on RDS, Aurora, Cloud SQL, AlloyDB, Supabase, and Neon. On self-managed Postgres, follow the pg_cron setup guide.With pg_cron available in the same database as PgQue:pgque_ticker every second, pgque_retry_events every 30 seconds, pgque_maint every 30 seconds, and pgque_rotate_step2 every 10 seconds.The pgque_ticker job calls CALL pgque.ticker_loop(), a procedure that re-invokes pgque.ticker() every tick_period_ms milliseconds inside a single 1-second cron slot, committing between iterations. The default is 100 ms (10 ticks/sec), giving ~50 ms median end-to-end delivery.Tune the rate at runtime without rescheduling — the change takes effect on the next cron slot (≤ 1 s):select * from pgque.status();.With pg_timetable
Run the external pg_timetable worker against the database where PgQue is installed:--clientname=pgque flag is required — pg_timetable only executes chains whose job_client_name matches the running worker’s client name. Keep this worker process running; unlike pg_cron, pg_timetable is an external scheduler process, not a Postgres background worker.Then register PgQue’s jobs:pgque.stop_timetable() removes the PgQue pg_timetable jobs. pgque.stop() stops whichever scheduler is active. Calling pgque.start_timetable() automatically removes existing PgQue pg_cron jobs first; pgque.start() does the same for pg_timetable jobs.Without any scheduler
PgQue installs and works withoutpg_cron or pg_timetable. Drive ticking and maintenance from your application or an external scheduler (system cron, systemd, a worker loop):pgque.ticker() at your target rate. tick_period_ms is only consulted by pgque.ticker_loop() (the pg_cron/pg_timetable path); outside that path, your driver controls the cadence.Skipping maint_retry_events() means nack’d events will never be redelivered.Grant roles
The install creates three roles. Application users do not need superuser — grant whichever role matches the access pattern.
DDL-class operations (
pgque_reader (consume) and pgque_writer (produce) are siblings, not parent/child. Apps that both produce and consume must be granted both roles explicitly.| Role | Purpose | Access |
|---|---|---|
pgque_reader | Consumers, dashboards, metrics | subscribe, receive, ack, nack, observability views |
pgque_writer | Producers | send, send_batch — does not inherit pgque_reader |
pgque_admin | Operators, migrations | Member of both, plus full schema access |
create_queue, drop_queue, start, ticker, force_next_tick, set_queue_config) require pgque_admin.Optional: install as a pg_tle extension
This is opt-in. The default\i sql/pgque.sql install is the recommended path. Use pg_tle only if you specifically want PgQue managed as a real Postgres extension (with alter extension pgque update and drop extension pgque cascade).
Note that pg_tle is itself a C extension that requires shared_preload_libraries — the dependency the default install avoids. Available on AWS RDS / Aurora and self-hosted Postgres.
On self-hosted Postgres, inspect the current list before modifying it to avoid overwriting existing entries:
\i sql/pgque-tle-uninstall.sql.
pg_cron log hygiene
pg_cron logs every job execution to cron.job_run_details with no built-in purge. PgQue’s four scheduled jobs add roughly 5,000 rows per hour. The table grows forever unless you intervene.
The recommended approach is to keep pg_cron logging enabled (for other jobs’ run history) and purge only PgQue’s high-volume entries:
