Workload Basics
OLTP wants low-latency short transactions. OLAP wants large scans, sorts, and parallelism. The same PostgreSQL 18.4 instance cannot maximize both without guardrails or topology splits.
Search across all documentation pages
OLTP wants low-latency short transactions. OLAP wants large scans, sorts, and parallelism. The same PostgreSQL 18.4 instance cannot maximize both without guardrails or topology splits.
Quick-reference recipe card - copy-paste ready.
-- OLTP role defaults
ALTER ROLE oltp_app SET statement_timeout = '5s';
ALTER ROLE oltp_app SET work_mem = '16MB';
-- Reporting role defaults (separate pool)
ALTER ROLE reporting SET statement_timeout = '30min';
ALTER ROLE reporting SET work_mem = '256MB';When to reach for this: Designing cluster defaults before mixing checkout API and BI dashboards on one primary.
CREATE TABLE orders (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
customer_id bigint NOT NULL,
total numeric(12,2) NOT NULL,
created_at timestamptz NOT NULL DEFAULT now()
);
INSERT INTO orders (customer_id, total, created_at)
SELECT (random() * 10000)::bigint, (random() * 500)::numeric(12,2), now() - (random() * interval '365 days')
FROM generate_series(1, 500000);
-- OLTP shape: point read
EXPLAIN (ANALYZE, BUFFERS)
SELECT total FROM orders WHERE id = 12345;
-- OLAP shape: aggregate scan
EXPLAIN (ANALYZE, BUFFERS)
SELECT date_trunc('month', created_at) AS month, sum(total)
FROM orders
GROUP BY 1
ORDER BY 1;What this demonstrates:
work_mem default poorly serves bothwork_mem, max_parallel_workers_per_gather, effective_io_concurrency, statement_timeout.| GUC | OLTP bias | OLAP bias |
|---|---|---|
| work_mem | Low (4-32MB) | Higher per reporting role |
| parallel gathers | 0-2 on primary | Higher on replica |
| statement_timeout | Seconds | Minutes on batch role |
| random_page_cost | Tuned for SSD OLTP | Less critical on seq scans |
SELECT rolname, rolconfig
FROM pg_roles
WHERE rolname IN ('oltp_app', 'reporting');work_mem only on reporting.max_parallel_workers_per_gather = 0 for OLTP role optional.| Alternative | Use When | Don't Use When |
|---|---|---|
| Read replica | Offload reporting | Lag unacceptable |
| Columnar warehouse | Heavy BI | Ops budget tiny |
| Materialized views | Repeated aggregates | Real-time KPIs |
Yes with strict pools, timeouts, and replica routing; not with one shared role.
PostgreSQL is OLTP-first; analytics needs guardrails or external systems.
When replica lag and OLTP p95 correlate with BI schedule repeatedly.
Filter by userid and query patterns to quantify OLAP cost.
Small reporting pool_size limits concurrent cache killers.
Run OLAP batch ETL off-peak even on replicas.
Same role/timeout patterns apply on managed replicas.
CDC resembles OLAP; separate slot monitoring.
Review release notes; still tune per role.
Read replicas for reporting routing patterns.
Stack versions: This page was written for PostgreSQL 18.4 (stable 18, maintenance 17), pgvector 0.8+, PgBouncer 1.x, Patroni 3.x, and PostGIS 3.5+.
Reviewed by Chris St. John·Last updated Jul 19, 2026