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.

All observability functions in the default install are granted to pgque_reader. They flow up to pgque_admin but not to pgque_writer — a producer-only role cannot inspect consumer state.

get_queue_info

pgque.get_queue_info() → setof record
pgque.get_queue_info(queue text) → setof record
Returns one row per queue with ticker configuration and live stats. The 1-argument form filters to a single queue.
select * from pgque.get_queue_info();
select * from pgque.get_queue_info('orders');
ColumnTypeDescription
queue_nametextQueue name
queue_ntablesintegerNumber of rotation tables (default 3)
queue_cur_tableintegerIndex of the currently active rotation table
queue_rotation_periodintervalHow often the hot table rotates
queue_switch_timetimestamptzWhen the last rotation occurred
queue_external_tickerbooleanWhether ticking is driven externally
queue_ticker_pausedbooleanWhether the ticker is paused for this queue
queue_ticker_max_countintegerForce tick after N events (default 500)
queue_ticker_max_lagintervalForce tick after this wall time (default 3 s)
queue_ticker_idle_periodintervalIdle tick interval (default 1 min)
ticker_lagintervalWall time since the last tick — key health signal
ev_per_secfloat8Recent event ingestion rate
ev_newbigintEvents waiting for the next tick
last_tick_idbigintMost recent tick id

get_consumer_info

pgque.get_consumer_info() → setof record
pgque.get_consumer_info(queue text) → setof record
pgque.get_consumer_info(queue text, consumer text) → setof record
Returns one row per consumer. Filter by queue, or by both queue and consumer name. Either argument in the 2-arg form may be NULL to widen the selection.
select * from pgque.get_consumer_info();
select * from pgque.get_consumer_info('orders');
select * from pgque.get_consumer_info('orders', 'processor');
ColumnTypeDescription
queue_nametextQueue name
consumer_nametextConsumer name
lagintervalAge of the last finished batch — high means falling behind
last_seenintervalTime since the consumer last processed a batch
last_tickbigintLast tick id the consumer processed
current_batchbigintActive batch id (null if none open)
next_tickbigintNext tick to process (null if up to date)
pending_eventsbigintEvents waiting for this consumer

get_batch_info

pgque.get_batch_info(batch_id bigint) → record
Inspects an active batch. Useful for debugging stuck consumers.
select * from pgque.get_batch_info(42);
ColumnTypeDescription
queue_nametextQueue name
consumer_nametextConsumer that owns the batch
batch_starttimestamptzWhen the batch was opened
batch_endtimestamptzBatch close time (null if still active)
prev_tick_idbigintStart of the tick window
tick_idbigintEnd of the tick window
lagintervalAge of the batch
seq_startbigintEvent sequence start
seq_endbigintEvent sequence end

Experimental observability

These functions are not part of the default install. Load them explicitly. APIs may change before promotion to stable.
\i sql/experimental/observability.sql
FunctionDescription
pgque.queue_stats()Per-queue depth, DLQ count, rotation age, ticker state
pgque.consumer_stats()Per-consumer lag, pending events, active batch info
pgque.queue_health()Operational checks: stuck ticker, rotation lag, DLQ growth
pgque.otel_metrics()OTel-compatible metric export rows (metric_name, metric_type, metric_value, labels)
pgque.stuck_consumers(threshold interval)Consumers idle longer than threshold (default 1 hour)
pgque.in_flight(queue text)Active batches per consumer with age and estimated event count
pgque.throughput(queue, period, bucket_size)Events/sec bucketed over a time window
pgque.error_rate(queue, period, bucket_size)Retries and dead letters bucketed over a time window

Build docs developers (and LLMs) love