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.

Queue management functions create, remove, and configure PgQue queues. All require the pgque_admin role.

create_queue

pgque.create_queue(queue text) → integer
Creates a queue with default settings: 3 rotation tables, built-in ticker enabled. Returns 1 if created, 0 if a queue with that name already exists (idempotent). Queue names are limited to 57 bytes (UTF-8). The pgque_<name> LISTEN/NOTIFY channel must fit within PostgreSQL’s 63-byte identifier limit.
select pgque.create_queue('orders');
-- returns 1 on creation, 0 if already exists

drop_queue

pgque.drop_queue(queue text) → integer
pgque.drop_queue(queue text, force bool) → integer
Drops a queue. The 1-argument form fails if any consumers are still attached. Pass force => true to unregister all attached consumers first.
-- fails if consumers are attached
select pgque.drop_queue('orders');

-- unregisters consumers first, then drops
select pgque.drop_queue('orders', true);

set_queue_config

pgque.set_queue_config(queue text, param text, value text) → integer
Sets one queue parameter. The param argument uses the short name (without the queue_ prefix) — set_queue_config prepends it internally.
select pgque.set_queue_config('orders', 'max_retries', '5');
select pgque.set_queue_config('orders', 'ticker_max_count', '1000');
select pgque.set_queue_config('orders', 'rotation_period', '4 hours');
Passing SQL NULL as value resets the column to its schema default.

Configurable parameters

Param (short name)TypeDescriptionDefault
ticker_max_countintegerForce a tick after this many events500
ticker_max_lagintervalForce a tick after this wall time since the last tick3 seconds
ticker_idle_periodintervalTick interval when the queue is idle1 minute
ticker_pausedbooleanPause ticking for this queuefalse
rotation_periodintervalHow often the hot event table rotates2 hours
external_tickerbooleanTicks are pushed from an external clock sourcefalse
max_retriesintegerMax nack retries before routing to the DLQ3
Range checks: max_retries >= 0; ticker counts, lags, idle periods, and rotation periods must be positive.
Pausing a queue stops tick creation — events still accumulate but consumers see nothing new. Resume with set_queue_config(queue, 'ticker_paused', 'false'). The experimental sql/experimental/config_api.sql adds pause_queue() and resume_queue() shortcut functions.

Build docs developers (and LLMs) love