pg_later
pg_later · Run queries now and get results later
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1090 | pg_later | pg_later | 0.5.0 | TIME | PostgreSQL | Rust |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | pglater |
| Requires | pgmq |
| See Also | pg_task pg_cron pg_dispatch pgagent pg_dbms_job pg_background pg_durable omni_worker pg_jobmon |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 0.4.0 | PIGSTY 0.4.0 | PIGSTY 0.4.0 | PIGSTY 0.4.0 |
| el8.aarch64 | N/A | PIGSTY 0.4.0 | PIGSTY 0.4.0 | PIGSTY 0.4.0 | PIGSTY 0.4.0 |
| el9.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| el9.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| el10.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| el10.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| d12.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| d12.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| d13.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| d13.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| u22.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| u22.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| u24.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| u24.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| u26.x86_64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
| u26.aarch64 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 | PIGSTY 0.5.0 |
Source
github.com/ChuckHend/pg_later
pg_later-0.5.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
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.
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:
Execute a SQL query now:
Come back at some later time, and retrieve the results by providing the job id:
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.initcreates 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.