pg_dispatch
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_dispatch | 0.1.5 | TIME | PostgreSQL | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1100 | pg_dispatch | No | No | No | Yes | No | No | - |
| Related | pgcrypto 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
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.1.5 | 1817161514 | pg_dispatch | pgcrypto, pg_cron |
| RPM | PIGSTY | 0.1.5 | 1817161514 | pg_dispatch_$v | - |
| DEB | PIGSTY | 0.1.5 | 1817161514 | postgresql-$v-pg-dispatch | postgresql-$v-cron |
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_cron1.5.0 or newerpgcrypto
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.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.