OLAP vs. OLTP

Two workloads with opposite access patterns, and why one database rarely serves both well.

Two different jobs

(online transaction processing) handles the operational side of a business: creating an order, updating an account balance, placing a reservation. These are short, frequent transactions that read and write a handful of rows at a time.

(online analytical processing) handles analysis: how many orders shipped last quarter by region, what is the average order value by customer segment. These queries scan and aggregate millions of rows, but run far less frequently.

Why the same schema struggles at both

OLTP schemas are to make single-row writes fast and consistent: minimal duplication, strict foreign keys, row-oriented storage so a whole record can be fetched or updated in one disk read.

Running an analytical aggregation against a normalized OLTP schema means joining many tables and scanning rows the query doesn't need column-by-column, which is slow precisely because the storage layout optimizes for the opposite access pattern.

OLTP vs. OLAP

OLTPOLAP
Typical queryInsert/update a single rowAggregate millions of rows
Schema shapeNormalized (star/snowflake)
Storage orientationRow-oriented
Optimized forWrite latency, consistencyScan and aggregation throughput

Why data warehouses exist

A data warehouse is a separate system, fed from OLTP sources, deliberately denormalized and column-oriented so analytical queries are fast without touching the production system that serves live transactions.

This separation also protects OLTP latency: a heavy analytical scan running directly against a production transactional database would compete for the same resources that need to stay fast for live customer traffic.

Cost / gotcha

Running analytics directly against a production OLTP database risks slowing down the live transactions that database exists to serve.

Practice / self-test

1. Why is a normalized schema good for OLTP but bad for OLAP?

Reveal answer

Normalization minimizes duplication and keeps single-row writes fast and consistent, which OLTP needs. But it forces OLAP queries to join many tables to answer a single analytical question, which is slow at scan scale.

2. Why shouldn't heavy analytical queries run directly against a production OLTP database?

Reveal answer

They compete for the same CPU, memory, and I/O that the OLTP system needs to keep live transactions fast, risking latency for actual customer-facing operations.