The hidden advantage of co‑locating workflow state
When a workflow engine stores its metadata in the same PostgreSQL instance that holds the business data, the two can participate in a single ACID transaction. This eliminates the split‑brain scenario where a database write succeeds but the workflow checkpoint does not, or vice‑versa. The result is exactly‑once execution for any step that updates data and a single‑transactional outbox for cross‑system events.
Solving idempotency without extra tables
Traditional durable workflows checkpoint after a step finishes, then resume from the last checkpoint on failure. If a crash occurs between the data write and the checkpoint, the step may be replayed, causing duplicate side effects such as double‑crediting a bank account. Engineers usually add an applied_payments table and guard every credit operation with a lookup‑then‑insert pattern [1].
By running the business update and the checkpoint insert in the same PostgreSQL transaction, the workflow either commits both rows or rolls back both. On recovery, the step is simply re‑executed because no checkpoint exists. This eliminates the need for application‑level idempotency logic, reduces schema bloat, and removes a whole class of bugs where the checkpoint and data diverge.
Transactional outbox becomes a single UDF call
Cross‑service communication often relies on the transactional outbox pattern: a table stores outbound messages, and a separate poller delivers them. While reliable, it introduces operational overhead—polling workers, retry queues, and reconciliation jobs to fix drift between the outbox and the primary tables [2].
Co‑located workflows replace the outbox with a PostgreSQL user‑defined function (UDF) that enqueues a workflow row in the same transaction that updates the core business record. The enqueue operation is just another row insert, so the database guarantees atomicity: either the record and the workflow entry are persisted together, or neither is. A downstream worker then dequeues the row and performs the external call (e.g., notifying a warehouse). The pattern preserves the benefits of the outbox—reliable delivery and decoupling—while slashing the infrastructure footprint.
Business impact: cost, risk, and organization
- Cost reduction – Fewer moving parts mean lower cloud‑instance spend and fewer managed services. A single PostgreSQL cluster replaces a database, a message queue, and a polling service.
- Risk mitigation – ACID guarantees remove the “partial‑commit” window that historically caused data inconsistency, regulatory audit failures, and customer‐facing errors.
- Organizational change – Teams can consolidate the data‑engineer and platform‑engineer responsibilities around a single PostgreSQL platform, speeding up onboarding and reducing the need for bespoke DevOps pipelines.
Real‑world validation
The DBOS team demonstrated the approach in a June 2026 blog post, showing how a enqueue_workflow UDF eliminates the need for a separate outbox table and polling process [3]. The article sparked discussion on Hacker News and Reddit, where practitioners highlighted that co‑location “eliminates an entire class of distributed‑system problems” and offers a “secret weapon” for building resilient services [4][5].
When not to co‑locate
The model assumes that the workflow’s latency requirements fit within PostgreSQL’s transaction model. Extremely long‑running tasks or those that need to interact with multiple heterogeneous stores may still benefit from an external orchestrator. However, for the majority of CRUD‑centric microservices, the trade‑off leans heavily toward in‑database workflows.


