Internal Tables

Overview

pgq.queueQueue configuration
pgq.consumerConsumer names
pgq.subscriptionConsumer registrations
pgq.tickPer-queue snapshots (ticks)
pgq.event_*Data tables
pgq.retry_queueEvents to be retried later

Standard triggers store events in the pgq.event_* data tables There is one top event table pgq.event_<queue_id> for each queue inherited from pgq.event_template wuith three tables for actual data pgq.event_<queue_id>_0 to pgq.event_<queue_id>_2.

The active table is rotated at interval, so that if all the consubers have passed some poin the oldes one can be emptied using TRUNCATE command for efficiency

Summary
Internal Tables
pgq.consumerName to id lookup for consumers
pgq.queueInformation about available queues
pgq.tickSnapshots for event batching
pgq.subscriptionConsumer registration on a queue.
pgq.event_templateParent table for all event tables
pgq.retry_queueEvents to be retried.

pgq.consumer

Name to id lookup for consumers

Columns

co_idconsumer’s id for internal usage
co_nameconsumer’s id for external usage

pgq.queue

Information about available queues

Columns

queue_idqueue id for internal usage
queue_namequeue name visible outside
queue_ntableshow many data tables the queue has
queue_cur_tablewhich data table is currently active
queue_rotation_periodperiod for data table rotation
queue_switch_step1tx when rotation happened
queue_switch_step2tx after rotation was committed
queue_switch_timetime when switch happened
queue_external_tickerticks come from some external sources
queue_ticker_pausedticker is paused
queue_disable_insertdisallow pgq.insert_event()
queue_ticker_max_countbatch should not contain more events
queue_ticker_max_lagevents should not age more
queue_ticker_idle_periodhow often to tick when no events happen
queue_per_tx_limitMax number of events single TX can insert
queue_data_pfxprefix for data table names
queue_event_seqsequence for event id’s
queue_tick_seqsequence for tick id’s
queue_extra_maintarray of functon names to call during maintenance

pgq.tick

Snapshots for event batching

Columns

tick_queuequeue id whose tick it is
tick_idticks id (per-queue)
tick_timetime when tick happened
tick_snapshottransaction state
tick_event_seqlast value for event seq

pgq.subscription

Consumer registration on a queue.

Columns

sub_idsubscription id for internal usage
sub_queuequeue id
sub_consumerconsumer’s id
sub_last_ticklast tick the consumer processed
sub_batchshortcut for queue_id/consumer_id/tick_id
sub_next_tickbatch end pos

pgq.event_template

Parent table for all event tables

Columns

ev_idevent’s id, supposed to be unique per queue
ev_timewhen the event was inserted
ev_txidtransaction id which inserted the event
ev_ownersubscription id that wanted to retry this
ev_retryhow many times the event has been retried, NULL for new events
ev_typeconsumer/producer can specify what the data fields contain
ev_datadata field
ev_extra1extra data field
ev_extra2extra data field
ev_extra3extra data field
ev_extra4extra data field

pgq.retry_queue

Events to be retried.  When retry time reaches, they will be put back into main queue.

Columns

ev_retry_aftertime when it should be re-inserted to main queue
ev_queuequeue id, used to speed up event copy into queue
*same as pgq.event_template
Close