Verdict: For teams building AI agents or data pipelines, pg_durable is a game-changer that eliminates the need for external task queues like Redis or Temporal. By bringing durable execution directly into PostgreSQL 17, it allows you to run fault-tolerant, long-running workflows with zero extra infrastructure.
Last verified: July 11, 2026 • Status: Public Preview • Compatibility: PostgreSQL 17 & 18 • Core Value: In-database durable execution. Pricing/versions change often — last checked against official Microsoft July 2026 release data.
What is pg_durable?
pg_durable is a Microsoft-developed open-source PostgreSQL extension that implements the "durable execution" pattern. Unlike standard SQL functions that fail if the database restarts, a pg_durable function is a graph of steps that checkpoints its state to disk at every turn. If the database crashes, execution resumes exactly where it left off.
This effectively turns Postgres into a native workflow orchestrator, allowing you to stop "stitching" together cron jobs, background workers, and status tables.
Why Durable Execution Matters for AI Teams
Durable execution is the "unglamorous backbone" of reliable agentic workflows. When you are chunking data for AI vector embeddings or calling external APIs that might time out, you need a system that handles retries and state recovery automatically.
The "Old" Way:
- Database stores state.
- Message Queue (Redis/RabbitMQ) handles tasks.
- Background Workers (Python/Node) execute logic.
- Scheduler (Cron) triggers work.
The pg_durable Way:
- PostgreSQL 17 handles everything.
- Workflows are defined in SQL and executed by a native background worker.
- State is managed via internal tables, surviving crashes and failovers.
Core Features and Operators
The extension introduces a domain-specific language (DSL) within SQL for building complex graphs.
| Operator | Purpose | Example |
|---|---|---|
~> |
Sequence | Run Step A, then Step B. |
|=> |
Variable Binding | Save Step A result into a variable for Step B. |
& |
Parallel | Run Step A and Step B at the same time. |
Key Functions
df.start(graph): Initiates a new durable workflow.df.status(id): Checks the progress of a running task.df.signal(id, name, data): Wakes a "parked" workflow for human-in-the-loop approval.
3 Production Use Cases for 2026
Teams are already using pg_durable to simplify autonomous AI SEO and data ingest:
- Vector Embedding Pipelines: Automatically chunk text, call an embedding API, and upsert into
pgvector0.8.2. - Human-in-the-Loop Approvals: Start a workflow, "park" it for 24 hours while waiting for a
df.signalfrom a manager, then commit changes. - Scheduled Maintenance: Use
df.waitwith cron expressions to refresh materialized views or detect table bloat without external schedulers.
How to Install pg_durable
pg_durable is available for PostgreSQL 17 and 18. It requires the duroxide Rust runtime (included in official packages).
1. Official Docker Image
The fastest way to test is the official GitHub Container Registry image:
docker run --name pg-durable -e POSTGRES_PASSWORD=*** -d ghcr.io/microsoft/pg_durable:latest
2. Manual Installation (Ubuntu 24.04)
sudo apt install -y postgresql-17-pg_durable
# Edit postgresql.conf
# shared_preload_libraries = 'pg_durable'
# Restart Postgres
sudo systemctl restart postgresql
3. Enable Extension
CREATE EXTENSION pg_durable;
SELECT df.grant_usage('your_app_role');
What this means for you
If you are currently managing a fleet of Celery or BullMQ workers just to update database rows, you can likely delete hundreds of lines of boilerplate. pg_durable lets your database handle the reliability of the workflow, so your productivity engines can focus on the business logic.
FAQ
Q: Does pg_durable replace Temporal? A: For SQL-heavy workflows, yes. However, if your steps require complex in-memory control flow or non-HTTP SDKs, a general-purpose orchestrator like Temporal is still superior.
Q: Can it run parallel tasks?
A: Yes, using the & operator or df.join, you can fan out into multiple parallel queries and wait for all to finish before joining results.
Q: Is it safe for production? A: It is currently in Public Preview. While stable on Azure HorizonDB, self-hosted users should benchmark carefully, as background workers consume database resources.
Q: How does it handle retries?
A: Retries are automatic and deterministic. If a step fails due to a transient error, the duroxide runtime re-executes the node based on your configured policy.
Discussion
0 comments