Skip to main content

Documentation 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 is tick-based: producers append events to a queue, but consumers only see events once a tick has been recorded. Without a running ticker, enqueues still work but nothing is ever delivered. This guide covers all three scheduling options — pg_cron, pg_timetable, and external schedulers — and explains how to tune the tick rate.

How ticking works

pgque.start() schedules a single 1-second pg_cron slot that calls CALL pgque.ticker_loop(). The ticker_loop procedure internally re-invokes pgque.ticker() every tick_period_ms milliseconds (default 100 ms = 10 ticks/sec), committing between iterations so each tick gets its own transaction and snapshot. Four pg_cron jobs are scheduled by pgque.start():
Job nameSchedulePurpose
pgque_tickerevery 1 sCalls ticker_loop(), which ticks every 100 ms inside the slot
pgque_retry_eventsevery 30 sMoves nack’d events back into the main stream
pgque_maintevery 30 sRotation step 1, queue maintenance hooks
pgque_rotate_step2every 10 sRotation step 2 (must run in its own transaction)
PgQue does not deliver messages without a working ticker. Enqueueing still works, but consumers see nothing new because no tick boundaries are created.

Scheduling options

Tuning the tick rate

The default tick rate is 10 ticks/sec (100 ms period). Tune at runtime — no need to call start() again:
select pgque.set_tick_period_ms(50);    -- 20 ticks/sec, ~25 ms median e2e latency
select pgque.set_tick_period_ms(100);   -- 10 ticks/sec (default), ~50 ms median
select pgque.set_tick_period_ms(200);   -- 5 ticks/sec, ~100 ms median
select pgque.set_tick_period_ms(1000);  -- 1 tick/sec, ~500 ms median (pgqd-compatible)
Valid values are exact divisors of 1000 in the 1–1000 ms range. The change takes effect on the next pg_cron slot (within 1 second), without rescheduling.
Tick periodTicks/secMedian e2e latencyWAL/day (per active queue)
10 ms100~5 ms~2.4 GiB
50 ms20~25 ms~480 MiB
100 ms10 (default)~50 ms~240 MiB
200 ms5~100 ms~120 MiB
1000 ms1~500 ms~24 MiB
WAL estimates apply only to queues that materialize ticks continuously (active producers). Idle queues back off toward ticker_idle_period (default 1 minute) and produce negligible WAL.
Inspect the current configuration:
select * from pgque.status();

Build docs developers (and LLMs) love