pg_dispatch

Asynchronous SQL dispatcher built on pg_cron

Overview

PackageVersionCategoryLicenseLanguage
pg_dispatch0.1.5TIMEPostgreSQLSQL
IDExtensionBinLibLoadCreateTrustRelocSchema
1100pg_dispatchNoNoNoYesNoNo-
Relatedpgcrypto pg_cron pg_cron pg_task pg_later pg_background

Pure SQL extension; runtime also needs pgcrypto from contrib in addition to pg_cron.

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.1.51817161514pg_dispatchpgcrypto, pg_cron
RPMPIGSTY0.1.51817161514pg_dispatch_$v-
DEBPIGSTY0.1.51817161514postgresql-$v-pg-dispatchpostgresql-$v-cron
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
d12.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
d13.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
d13.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u22.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u22.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u24.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
u24.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5

Build

You can build the RPM / DEB packages for pg_dispatch using pig build:

pig build pkg pg_dispatch         # build RPM / DEB packages

Install

You can install pg_dispatch directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_dispatch;          # Install for current active PG version
pig ext install -y pg_dispatch -v 18  # PG 18
pig ext install -y pg_dispatch -v 17  # PG 17
pig ext install -y pg_dispatch -v 16  # PG 16
pig ext install -y pg_dispatch -v 15  # PG 15
pig ext install -y pg_dispatch -v 14  # PG 14
dnf install -y pg_dispatch_18       # PG 18
dnf install -y pg_dispatch_17       # PG 17
dnf install -y pg_dispatch_16       # PG 16
dnf install -y pg_dispatch_15       # PG 15
dnf install -y pg_dispatch_14       # PG 14
apt install -y postgresql-18-pg-dispatch   # PG 18
apt install -y postgresql-17-pg-dispatch   # PG 17
apt install -y postgresql-16-pg-dispatch   # PG 16
apt install -y postgresql-15-pg-dispatch   # PG 15
apt install -y postgresql-14-pg-dispatch   # PG 14

Create Extension:

CREATE EXTENSION pg_dispatch CASCADE;  -- requires: pgcrypto, pg_cron

Usage

Source: README, database.dev page

pg_dispatch is a TLE-compatible async SQL dispatcher built on pg_cron. It is intended for deferring side effects out of the caller’s main transaction in sandboxed environments such as RDS or Supabase.

Requirements and install

  • PostgreSQL 13+
  • pg_cron 1.5.0+
  • pgcrypto
SELECT dbdev.install(Snehil_Shah@pg_dispatch);
CREATE EXTENSION "Snehil_Shah@pg_dispatch";

The extension installs into the pgdispatch schema.

Main functions

SELECT pgdispatch.fire('SELECT pg_sleep(40);');
SELECT pgdispatch.snooze('SELECT pg_sleep(20);', '20 seconds');
  • pgdispatch.fire(command text): enqueue SQL for immediate async execution.
  • pgdispatch.snooze(command text, delay interval): enqueue SQL for delayed async execution.

Typical use

The official README positions pg_dispatch for PL/pgSQL or trigger-based workflows where a foreground RPC should commit quickly while notifications, analytics updates, or other expensive SQL run later in a separate transaction.

Caveats

  • The runtime dependency on pgcrypto is in addition to pg_cron.
  • The delay argument truncates to seconds precision.
  • The project documents TLE/database.dev installation first; manual PGXN installation is also linked from the README.

Last Modified 2026-04-19: update extension stub docs (9f178c3)