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

Syntax:

CREATE EXTENSION "Snehil_Shah@pg_dispatch";
SELECT pgdispatch.fire('SELECT pg_sleep(40);');
SELECT pgdispatch.snooze('SELECT pg_sleep(20);', '20 seconds');

Sources: README, database.dev page

pg_dispatch is an asynchronous SQL dispatcher for PostgreSQL. It is designed as a TLE-compatible alternative to pg_later, built on top of pg_cron, so it can be used in environments such as Supabase and AWS RDS.

Prerequisites

The upstream README lists:

  • PostgreSQL 13 or newer
  • pg_cron 1.5.0 or newer
  • pgcrypto

Installation

The documented TLE installation path is:

SELECT dbdev.install(Snehil_Shah@pg_dispatch);
CREATE EXTENSION "Snehil_Shah@pg_dispatch";

The README warns that the extension installs into the pgdispatch schema and can collide with an existing schema of the same name.

Functions

pgdispatch.fire(command text)

Dispatch an SQL command for asynchronous execution:

SELECT pgdispatch.fire('SELECT pg_sleep(40);');

pgdispatch.snooze(command text, delay interval)

Dispatch a delayed SQL command:

SELECT pgdispatch.snooze('SELECT pg_sleep(20);', '20 seconds');

The README notes that the delay is scheduled asynchronously and does not block the caller’s main transaction.

Use Cases

The project positions itself for database-native async side effects, especially in PL/pgSQL or trigger-based workflows. Its example use case is moving expensive notification or analytics work out of an AFTER INSERT trigger so the main RPC or application request can return sooner.


Last Modified 2026-04-14: update extension catalog (29617e5)