pg_dispatch

pg_dispatch

pg_dispatch : Asynchronous SQL dispatcher built on pg_cron

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1100
pg_dispatch
pg_dispatch
0.1.5
TIME
PostgreSQL
SQL
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
----d--
No
No
No
Yes
no
no
Relationships
Requires
pgcrypto
pg_cron
See Also
pg_cron
pg_task
pg_later
pg_background

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

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
0.1.5
18
17
16
15
14
pg_dispatchpgcrypto, pg_cron
RPM
PIGSTY
0.1.5
18
17
16
15
14
pg_dispatch_$v-
DEB
PIGSTY
0.1.5
18
17
16
15
14
postgresql-$v-pg-dispatchpostgresql-$v-cron
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
el8.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
el9.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
el9.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
el10.x86_64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
el10.aarch64
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
PIGSTY 0.1.5
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

Source

pig build pkg pg_dispatch;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

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

Install this extension with pig:

pig install pg_dispatch;		# install via package name, for the active PG version

pig install pg_dispatch -v 18;   # install for PG 18
pig install pg_dispatch -v 17;   # install for PG 17
pig install pg_dispatch -v 16;   # install for PG 16
pig install pg_dispatch -v 15;   # install for PG 15
pig install pg_dispatch -v 14;   # install for PG 14

Create this extension with:

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 updated on