scribase
Jobs, queues and partitionsversion 1.13.0

pgmq

Message queues in SQL: send, read with a visibility timeout, archive.

What it is for

pgmq is a lightweight queue built on tables. A reader takes messages with a visibility timeout; if it crashes, the message becomes visible again after the timeout. Delete or archive a message once it is handled. Because it is Postgres, enqueueing can be part of the same transaction as the write that caused it.

Enable it

sql
create extension if not exists pgmq;

Example

sql
select pgmq.create('emails');

select pgmq.send('emails', '{"to": "ana@example.com", "template": "welcome"}');

-- take up to 5 messages, hidden from other readers for 30 seconds
select msg_id, message from pgmq.read('emails', 30, 5);

select pgmq.archive('emails', 1);

Questions

How do I enable pgmq?

Run create extension if not exists pgmq; in the SQL editor, or switch it on from the Extensions page in the console. You do not need superuser access.

Which version of pgmq is installed?

1.13.0, on Postgres 17.6, as read from the running engine on 2026-10-08. Check yours with: select extversion from pg_extension where extname = 'pgmq';

Upstream project: github.com/pgmq/pgmq

More jobs, queues and partitions extensions

  • pg_cron Run SQL on a schedule written in cron syntax.
  • pg_partman Create and drop time or number partitions for you.