Isolating AI Workloads From OLTP Traffic in Postgres
Separate your AI workloads from live transactions to protect database performance.

Isolating AI workloads from OLTP traffic in Postgres is a requirement for transactional reliability. AI agents change state often and run heavy analytical queries, which puts pressure on the resources that live requests need. Workloads need to be separated according to the contention they cause, with governance over how agents reach the data.
Why AI workloads are structurally different database clients than the applications Postgres was designed for
Traditional web applications have fairly predictable request-response cycles, with index lookups, point reads, and narrow row writes. Postgres’s row storage, MVCC, and shared buffer pool suit that pattern. The database handles a request with a set scope, then hands control back to the application. An AI agent, by contrast, can perform many database operations within one interaction. AI agents generate more traffic and a less predictable mix of work.
ClickHouse characterizes AI agents as “chatty database clients”. A single run can read conversation history, retrieve context, update a checkpoint, record tool calls, and append new state. Those operations belong on the transactional path and need predictable P99 latency. The same run also produces traces, token usage, tool outcomes, evaluation results, and latency distributions. Aggregating that data across thousands or millions of runs creates queries far heavier than the reads and writes needed to keep an individual interaction moving.
That combination makes AI a difficult co-tenant. AI needs Postgres for its live operations, but asking the same database to analyze those operations gives it very different work to do. OpenAI reports that a single primary with nearly 50 read replicas served 800 million users, but an expensive query that joined many tables still used all the CPU and caused high-severity incidents. Write storms from new feature launches created a separate challenge. Scale alone therefore does not explain the risk, because the shape of the work matters as much as its volume.
The three mechanical ways AI and analytical workloads degrade OLTP performance in Postgres
The first mechanism is buffer cache thrashing. Analytical scans load pages into shared buffers and displace hot transactional pages, forcing requests that previously read from memory back to disk. ClickHouse describes the consequence through a checkout endpoint that slows because someone runs a monthly revenue report. The requests need not touch the same business operation to interfere with each other. They compete through a finite buffer pool, so a scan changes the I/O demands of otherwise predictable transactions.
The second mechanism is MVCC write amplification. OpenAI identifies row versioning as a primary challenge under heavy write loads, because updating a tuple, even a single field, copies the entire row into a new version. Agents keep up this pressure when they write checkpoints and state updates often. Dead tuples accumulate, with overhead consuming 10–30% of CPU and I/O in write-heavy workloads. Queries face additional version work, while index maintenance adds to the cost of each stream of updates.
The third mechanism, autovacuum starvation, feeds that pressure back into the system. High write rates can create dead tuples faster than autovacuum processes them, while cleanup competes with production queries for disk I/O. As autovacuum falls behind, table bloat grows and index efficiency degrades. Queries then become slower against the bloated data, making the workload harder to sustain while cleanup remains under pressure. ClickHouse describes this deterioration as difficult to recover from without downtime.
WAL bloat follows a related path alongside that loop. Under sustained writes, Postgres can generate write-ahead log faster than replication slots drain it, filling the pg_wal directory and making WAL archiving a bottleneck. Together, cache eviction, row versioning, and delayed cleanup explain why reactive tuning can struggle once contention persists. An analytical scan consumes resources that transactional writes and maintenance also need. The resulting slowdown involves a linked system.

Why adding a read replica is a partial fix, not an isolation strategy
A read replica protects the primary by taking reporting queries off it. At moderate scale, that compute isolation can be enough to keep analytical scans from disturbing transactional reads. ClickHouse explicitly recognizes this benefit. Replicas are therefore a useful first step when reads dominate contention and primary write pressure remains manageable. Their limit is that they relocate execution without changing its model.
A replica is still a row-oriented Postgres instance with its own shared buffer pool. Analytical scans can thrash that pool even though the primary is protected from their direct cache effects. If transactional reads also use the replica, they can end up competing for the same shared buffer pool. Replicas can also have WAL apply lag and take more work to run. None of this removes the primary’s write amplification or cleanup burden.
Long analytical queries introduce a further constraint through replication conflicts. Postgres may cancel a query on a replica when it conflicts with incoming replication data, and max_standby_streaming_delay controls how long the replica waits before cancellation. The default is measured in seconds, so a ten-minute report can be terminated when the primary updates rows it is reading. Increasing the setting tolerates longer queries at the cost of more replication lag.
The isolation spectrum: three patterns ranked by what they actually decouple
The first pattern is query-level optimization on a single primary. It is the right starting point when a small number of slow queries account for most of the disruption. This pattern separates nothing physically, but reduces avoidable work before infrastructure is added. OpenAI tunes the application to reduce writes and uses rate-limited backfills and lazy writes to smooth out spikes. Its use of PgBouncer addresses connection exhaustion and setup latency, while idle_in_transaction_session_timeout prevents idle transactions from blocking autovacuum. These measures raise the ceiling, but they cannot change the execution model once cache thrashing and write amplification become persistent.
The second pattern is a read replica with analytical tuning. It decouples reporting compute from primary query execution, making it appropriate when scans are the dominant source of interference. Raising max_standby_streaming_delay gives long analytical queries more time, with the team accepting replication lag up front. This pattern works as long as the replica can handle reporting with cache pressure and data freshness loss that the team can accept. It reaches its ceiling when the displaced workload overwhelms the replica’s own row-oriented execution.
The third pattern is CDC replication into a dedicated analytical engine. This changes the execution model too, because analytical queries run on a columnar engine in place of another transactional row store. This avoids the 10–30x I/O amplification that Postgres row storage imposes when scanning wide tables for a handful of columns. Giving OLTP and analytical queries separate query I/O, memory, and vacuum budgets protects the resources needed to serve agent state updates from competition with heavy analysis.
ClickHouse says that use cases such as fraud detection and production incident diagnosis need transactional data ready for analysis almost at once, sooner than hourly or minutely ETL can deliver it. Supabase Pipelines (2026) addresses that requirement by streaming CDC from Postgres tables to a supported analytical destination in near real time. AWS Aurora with embedded DuckDB (2026) takes a different path, retaining transactional row storage and ACID guarantees while using columnar execution for external lakehouse workloads. Analytical scans can use dedicated Aurora read replicas, or working sets that are used often can be materialized locally. The dedicated-engine pattern needs setup, a managed analytical service, and replication monitoring, but it separates both the execution model and the compute.

When to trigger each isolation pattern: the signals that tell you the current tier has stopped working
Single-primary optimization has hit its limit when analytical scans push transaction latency above the service’s P99 target during normal operating hours. Accelerating dead tuple accumulation, measurable table bloat, and declining index efficiency signal that cleanup is also losing ground. Another warning is adding primary compute mainly to absorb aggregations. If scans dominate and write pressure is manageable, these signals support moving reporting to a tuned replica. If write pressure dominates, a read replica does not address the underlying failure.
The replica tier has stopped working when analytical cache pressure causes latency spikes for other reads routed there. Repeated query cancellations are another signal, especially when increasing max_standby_streaming_delay produces lag that violates freshness requirements. When reporting misses its own SLA while OLTP stays healthy, it points to a problem with the execution model. ClickHouse identifies similar breakpoints, including transaction latency breaches, missed reporting SLAs, interference with vacuum, and overprovisioning for aggregations.
AI agents as database clients require governance on top of isolation
Infrastructure isolation protects transactional resources from analytical work, but it does not control an agent’s access behavior. That behavior depends on continuing interaction with live data sources, external APIs, and internal databases. An agent needs infrastructure-level hard ceilings because it cannot tell on its own when to stop a strategy that is failing. Moving its queries to another database therefore leaves a distinct risk unresolved.
To keep access safe, production database credentials must stay out of the agent’s configuration. All agent database queries should pass through a centralized gateway that enforces permissions and logs access, with analytical queries directed to isolated read paths. Separate service accounts for each agent specialization provide attribution and limit scope. A support agent and a financial reporting agent should not share credentials, because their work must remain distinguishable during an audit or investigation. These controls govern who can ask for data even when the underlying compute is already isolated.
MCP (Model Context Protocol) gives agents an interface to data, but the tools it offers still need carefully set limits. Metric and semantic tools should take precedence over arbitrary SQL, expensive tools should be rate-limited, and action tools should remain behind approval. Semantic context matters because direct table access alone leaves an agent to guess at meaning. With context but no query access, the agent still cannot get an answer.
A governed data layer as the practical answer for Supabase teams running AI agents
For Supabase teams, Postgres is already the transactional home, and the primary should remain the system of record. Teams need to separate AI analysis without making a full warehouse-and-pipeline stack the price of reliable transactions. ClickHouse characterizes that ETL burden as costing teams thousands of engineering hours and hundreds of thousands of dollars annually. A governed data layer addresses the need to separate analytical work and remove agents’ dependence on production credentials together. This makes the architecture practical for teams without a dedicated data engineering function.
Replication and governance nevertheless remain different responsibilities. Supabase Pipelines (2026) handles the replication layer through near-real-time CDC into an analytical destination, avoiding the need to build a replication system. A governed data layer gives agents access to governed datasets through an MCP server in place of production tables with embedded credentials. The intended model requires no ETL infrastructure, schema changes, or separate data warehouse for the team to manage, with Postgres extended as the analytical home. Human teammates and AI agents then consume the same pre-calculated metrics, preventing different stakeholders from working from fragmented definitions.
The decision still follows the isolation spectrum rather than skipping directly to its most involved form. At modest scale, properly tuned read replicas are the right first step when analytical reads are the problem. When contention persists and agents are part of the workload, the next step must address both execution isolation and controlled access.


