Skip to content

pg_later

Run queries now and get results later

pg_later · Run queries now and get results later

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
1090pg_laterpg_later0.5.0TIMEPostgreSQLRust
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--sLd--NoYesYesYesnono

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXTPIGSTY0.5.019 18 17 16 15pg_laterpgmq
RPMPIGSTY0.5.019 18 17 16 15pg_later_$vpgmq_$v
DEBPIGSTY0.5.019 18 17 16 15postgresql-$v-pg-laterpostgresql-$v-pgmq
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 0.4.0PIGSTY 0.4.0PIGSTY 0.4.0PIGSTY 0.4.0
el8.aarch64N/APIGSTY 0.4.0PIGSTY 0.4.0PIGSTY 0.4.0PIGSTY 0.4.0
el9.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el9.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el10.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
el10.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d12.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d12.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d13.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
d13.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u22.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u22.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u24.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u24.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u26.x86_64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
u26.aarch64PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0PIGSTY 0.5.0
PackageVersionOSORGSIZEFile URL
pg_later_180.4.0el8.x86_64pigsty3.2 MiBpg_later_18-0.4.0-4PIGSTY.el8.x86_64.rpm
pg_later_180.4.0el8.aarch64pigsty2.9 MiBpg_later_18-0.4.0-4PIGSTY.el8.aarch64.rpm
pg_later_180.5.0el9.x86_64pigsty2.3 MiBpg_later_18-0.5.0-1PGSTY.el9.x86_64.rpm
pg_later_180.5.0el9.aarch64pigsty2.2 MiBpg_later_18-0.5.0-1PGSTY.el9.aarch64.rpm
pg_later_180.5.0el10.x86_64pigsty2.3 MiBpg_later_18-0.5.0-1PGSTY.el10.x86_64.rpm
pg_later_180.5.0el10.aarch64pigsty2.2 MiBpg_later_18-0.5.0-1PGSTY.el10.aarch64.rpm
postgresql-18-pg-later0.5.0d12.x86_64pigsty1.9 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~bookworm_amd64.deb
postgresql-18-pg-later0.5.0d12.aarch64pigsty1.7 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~bookworm_arm64.deb
postgresql-18-pg-later0.5.0d13.x86_64pigsty1.9 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~trixie_amd64.deb
postgresql-18-pg-later0.5.0d13.aarch64pigsty1.7 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~trixie_arm64.deb
postgresql-18-pg-later0.5.0u22.x86_64pigsty2.1 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~jammy_amd64.deb
postgresql-18-pg-later0.5.0u22.aarch64pigsty2.0 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~jammy_arm64.deb
postgresql-18-pg-later0.5.0u24.x86_64pigsty2.1 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~noble_amd64.deb
postgresql-18-pg-later0.5.0u24.aarch64pigsty2.0 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~noble_arm64.deb
postgresql-18-pg-later0.5.0u26.x86_64pigsty2.1 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~resolute_amd64.deb
postgresql-18-pg-later0.5.0u26.aarch64pigsty2.0 MiBpostgresql-18-pg-later_0.5.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_later_170.4.0el8.x86_64pigsty3.2 MiBpg_later_17-0.4.0-4PIGSTY.el8.x86_64.rpm
pg_later_170.4.0el8.aarch64pigsty2.9 MiBpg_later_17-0.4.0-4PIGSTY.el8.aarch64.rpm
pg_later_170.5.0el9.x86_64pigsty2.3 MiBpg_later_17-0.5.0-1PGSTY.el9.x86_64.rpm
pg_later_170.5.0el9.aarch64pigsty2.2 MiBpg_later_17-0.5.0-1PGSTY.el9.aarch64.rpm
pg_later_170.5.0el10.x86_64pigsty2.3 MiBpg_later_17-0.5.0-1PGSTY.el10.x86_64.rpm
pg_later_170.5.0el10.aarch64pigsty2.2 MiBpg_later_17-0.5.0-1PGSTY.el10.aarch64.rpm
postgresql-17-pg-later0.5.0d12.x86_64pigsty1.9 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~bookworm_amd64.deb
postgresql-17-pg-later0.5.0d12.aarch64pigsty1.7 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~bookworm_arm64.deb
postgresql-17-pg-later0.5.0d13.x86_64pigsty1.9 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~trixie_amd64.deb
postgresql-17-pg-later0.5.0d13.aarch64pigsty1.7 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~trixie_arm64.deb
postgresql-17-pg-later0.5.0u22.x86_64pigsty2.1 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~jammy_amd64.deb
postgresql-17-pg-later0.5.0u22.aarch64pigsty2.0 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~jammy_arm64.deb
postgresql-17-pg-later0.5.0u24.x86_64pigsty2.1 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~noble_amd64.deb
postgresql-17-pg-later0.5.0u24.aarch64pigsty2.0 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~noble_arm64.deb
postgresql-17-pg-later0.5.0u26.x86_64pigsty2.1 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~resolute_amd64.deb
postgresql-17-pg-later0.5.0u26.aarch64pigsty2.0 MiBpostgresql-17-pg-later_0.5.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_later_160.4.0el8.x86_64pigsty3.2 MiBpg_later_16-0.4.0-4PIGSTY.el8.x86_64.rpm
pg_later_160.4.0el8.aarch64pigsty2.9 MiBpg_later_16-0.4.0-4PIGSTY.el8.aarch64.rpm
pg_later_160.5.0el9.x86_64pigsty2.3 MiBpg_later_16-0.5.0-1PGSTY.el9.x86_64.rpm
pg_later_160.5.0el9.aarch64pigsty2.2 MiBpg_later_16-0.5.0-1PGSTY.el9.aarch64.rpm
pg_later_160.5.0el10.x86_64pigsty2.3 MiBpg_later_16-0.5.0-1PGSTY.el10.x86_64.rpm
pg_later_160.5.0el10.aarch64pigsty2.2 MiBpg_later_16-0.5.0-1PGSTY.el10.aarch64.rpm
postgresql-16-pg-later0.5.0d12.x86_64pigsty1.9 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~bookworm_amd64.deb
postgresql-16-pg-later0.5.0d12.aarch64pigsty1.7 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~bookworm_arm64.deb
postgresql-16-pg-later0.5.0d13.x86_64pigsty1.9 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~trixie_amd64.deb
postgresql-16-pg-later0.5.0d13.aarch64pigsty1.7 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~trixie_arm64.deb
postgresql-16-pg-later0.5.0u22.x86_64pigsty2.1 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~jammy_amd64.deb
postgresql-16-pg-later0.5.0u22.aarch64pigsty2.0 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~jammy_arm64.deb
postgresql-16-pg-later0.5.0u24.x86_64pigsty2.1 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~noble_amd64.deb
postgresql-16-pg-later0.5.0u24.aarch64pigsty2.0 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~noble_arm64.deb
postgresql-16-pg-later0.5.0u26.x86_64pigsty2.1 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~resolute_amd64.deb
postgresql-16-pg-later0.5.0u26.aarch64pigsty2.0 MiBpostgresql-16-pg-later_0.5.0-1PGSTY~resolute_arm64.deb
PackageVersionOSORGSIZEFile URL
pg_later_150.4.0el8.x86_64pigsty3.2 MiBpg_later_15-0.4.0-4PIGSTY.el8.x86_64.rpm
pg_later_150.4.0el8.aarch64pigsty2.9 MiBpg_later_15-0.4.0-4PIGSTY.el8.aarch64.rpm
pg_later_150.5.0el9.x86_64pigsty2.3 MiBpg_later_15-0.5.0-1PGSTY.el9.x86_64.rpm
pg_later_150.5.0el9.aarch64pigsty2.2 MiBpg_later_15-0.5.0-1PGSTY.el9.aarch64.rpm
pg_later_150.5.0el10.x86_64pigsty2.3 MiBpg_later_15-0.5.0-1PGSTY.el10.x86_64.rpm
pg_later_150.5.0el10.aarch64pigsty2.2 MiBpg_later_15-0.5.0-1PGSTY.el10.aarch64.rpm
postgresql-15-pg-later0.5.0d12.x86_64pigsty1.9 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~bookworm_amd64.deb
postgresql-15-pg-later0.5.0d12.aarch64pigsty1.7 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~bookworm_arm64.deb
postgresql-15-pg-later0.5.0d13.x86_64pigsty1.9 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~trixie_amd64.deb
postgresql-15-pg-later0.5.0d13.aarch64pigsty1.7 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~trixie_arm64.deb
postgresql-15-pg-later0.5.0u22.x86_64pigsty2.1 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~jammy_amd64.deb
postgresql-15-pg-later0.5.0u22.aarch64pigsty2.0 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~jammy_arm64.deb
postgresql-15-pg-later0.5.0u24.x86_64pigsty2.1 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~noble_amd64.deb
postgresql-15-pg-later0.5.0u24.aarch64pigsty2.0 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~noble_arm64.deb
postgresql-15-pg-later0.5.0u26.x86_64pigsty2.1 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~resolute_amd64.deb
postgresql-15-pg-later0.5.0u26.aarch64pigsty2.0 MiBpostgresql-15-pg-later_0.5.0-1PGSTY~resolute_arm64.deb

Source

pig build pkg pg_later;		# 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_later;		# install by package name

pig install pg_later -v 19;   # install for PG 19
pig install pg_later -v 18;   # install for PG 18
pig install pg_later -v 17;   # install for PG 17
pig install pg_later -v 16;   # install for PG 16
pig install pg_later -v 15;   # install for PG 15

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_later';

Create this extension with:

CREATE EXTENSION pg_later CASCADE; -- requires pgmq

Usage

Sources:

pg_later 0.5.0 runs SQL asynchronously through pgmq queues and returns a job ID for later result retrieval. The 0.5.0 source has PostgreSQL 15–19 build features; earlier releases supported older majors.

Configuration

The library requires shared_preload_libraries and a PostgreSQL restart. Append pg_later to the existing list. Configure the worker’s database connection explicitly: it chooses pglater.host, then PGLATER_SOCKET_URL, then DATABASE_URL. Socket settings use a URL with query parameters for host, port, user and database.

shared_preload_libraries = 'pg_later'
pglater.host = 'postgresql:///?host=/tmp&port=5432&user=pglater_worker&dbname=app'

Provision the worker role and its authentication separately, with only the permissions needed for queued statements and queues. Jobs run using that connection, not the submitting session’s role. Extension creation requires a superuser, and pgmq must be available. Initialize the queues in the worker’s configured database.

Getting Started

Initialize the extension’s backend:

CREATE EXTENSION pg_later CASCADE;
SELECT pglater.init();

Execute a SQL query now:

SELECT pglater.exec(
  'SELECT * FROM pg_available_extensions ORDER BY name LIMIT 2'
) AS job_id;
 job_id
--------
     1

Come back at some later time, and retrieve the results by providing the job id:

SELECT pglater.fetch_results(1);
{
  "query": "select * from pg_available_extensions order by name limit 2",
  "job_id": 1,
  "result": [
    {
      "name": "adminpack",
      "comment": "administrative functions for PostgreSQL",
      "default_version": "2.1",
      "installed_version": null
    },
    {
      "name": "amcheck",
      "comment": "functions for verifying relation integrity",
      "default_version": "1.3",
      "installed_version": null
    }
  ],
  "status": "success"
}

API and Operational Boundaries

  • pglater.exec(query, delay, validate) returns the queue message ID. Delay defaults to zero seconds; validation defaults to true and checks parsing, not authorization or safety.
  • pglater.fetch_results(job_id) returns JSON when a result exists and NULL while no result is available. Inspect its status to distinguish successful and failed jobs.
  • pglater.init creates the job and result queues. The worker archives processed jobs, including reported query failures; this is not automatic SQL retry.
  • Job SQL is logged, and result rows are materialized into JSON. Restrict queue access and avoid placing secrets in submitted statements. This worker API does not preserve the caller’s transaction or session state.

Table reader