Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path →
OLTP vs OLAP: row store, or column store?
A single storage-layout decision — rows laid out contiguously, or columns laid out contiguously — explains almost everything else in this comparison, including why running heavy analytics on your production database is a bad idea no matter how much hardware you throw at it.
The one distinction that decides everything
OLTP (online transaction processing) is optimized for many small, fast transactions — place an order, log in, update a row — using row-oriented, normalized storage. OLAP (online analytical processing) is optimized for complex aggregate queries over huge historical datasets — revenue by region by month — using column-oriented, often denormalized (star/snowflake schema) storage.
Powering the live application, touching individual records? OLTP. Powering dashboards, reporting, or ad-hoc analysis over historical data? OLAP. Virtually every real company needs both, connected by a pipeline.
Head to head
| Dimension | OLTP | OLAP |
|---|---|---|
| Query shape | Simple, touches few rows — "get this user’s cart" | Complex, scans/aggregates millions of rows |
| Storage layout | Row-oriented — a full row read is cheap | Column-oriented — reading one column is cheap |
| Schema | Normalized, minimizes redundancy for consistent writes | Denormalized star/snowflake, optimized for read speed |
| Write pattern | Frequent small writes, needs ACID transactions | Bulk loads / periodic ETL, batched not per-transaction |
| Concurrency | Many concurrent users, row-level locking | Fewer concurrent analysts, but each query is huge |
| Examples | Postgres, MySQL powering an app | Snowflake, BigQuery, ClickHouse, Redshift |
| Latency expectation | Milliseconds | Seconds to minutes is normal for a heavy query |
When to use each
Reach for OLTP
- Powering the live application
- Checkout, login, inventory updates
- Anything user-facing reading/writing individual records
- Needs ACID transaction guarantees
Reach for OLAP
- Business intelligence and dashboards
- Ad-hoc analyst queries over historical data
- ML feature aggregation over large windows
- Reporting that touches millions of rows at once
The pipeline, not a choice
Virtually every real company runs both: an OLTP database for the live app, and a continuous ETL or CDC (change data capture) pipeline replicating that data into an OLAP warehouse for analytics. This isn't redundancy — it's specifically so heavy analytical queries never compete for resources with, or slow down, the live transactional workload the actual product depends on.
An analyst's expensive query and a customer's checkout request have opposite resource profiles. Sharing one database means one eventually starves the other under real load.
Why row vs column layout is the whole story
An OLTP row store lays a full row contiguously on disk, so "fetch order #4471" is one cheap, localized read — exactly what a live application constantly needs. But "sum the revenue column across 50 million orders" on that same row store means reading every row's ENTIRE contents — every column, not just revenue — just to touch the one field you actually wanted, because the storage engine can't skip the columns you don't need when a row is stored as one contiguous chunk.
An OLAP column store inverts this: each column is stored contiguously instead of each row, so that same aggregate query reads ONLY the revenue column's bytes across all rows, skipping everything else entirely — and because a single column tends to hold far fewer distinct values than a full row (a "country" column repeats a small set of values millions of times), column-wise storage also compresses dramatically better. This single storage decision is the mechanical reason you can't just run serious analytics on your production Postgres at scale — it's not a licensing or feature limitation, it's that the row-oriented layout is doing exactly the wrong amount of I/O for an aggregate query by construction.
Row storage optimizes for "give me everything about one thing." Column storage optimizes for "give me one thing about everything." No single layout does both well — which is why the two systems specialize instead of merging.
A worked scenario: an online retailer’s checkout and finance report
An online retailer's checkout flow hits Postgres — OLTP — for every "place order," needing ACID guarantees and sub-100ms responses, one row (this order) at a time. This is precisely the row-store shape: small, frequent, individual-record transactions where consistency under concurrent writes matters more than anything else.
Meanwhile a CDC pipeline streams those same order rows into a Snowflake warehouse (or a nightly batch job loads them) — OLAP — where the finance team runs a query aggregating revenue by product category by region across three years of history. That exact query, run directly against the live Postgres instance, would table-scan a huge portion of production data and risk degrading checkout for real customers — but it's precisely what the column-oriented warehouse, built to skip everything except the columns the aggregate actually needs, handles as routine.
If a query touches one or a few records, it belongs on OLTP. If it aggregates across a large swath of history, it belongs on OLAP — running it on the wrong one either wastes I/O or risks the live application.
The flip point: how many columns your query touches
The crossover is measurable: a row store (OLTP) reads whole rows off disk; a columnar store (OLAP) reads only the columns a query references. For a query that touches k of N columns across many rows, the columnar store moves roughly k/N of the bytes.
A dashboard query summing 2 of 40 columns reads about 2/40 = 5% of the data — roughly 20× less I/O than a row store scanning full rows, which is why analytics lands on columnar. Flip it around: a transaction that reads or writes a whole row a few rows at a time gets that row in one place from the row store, while columnar would gather 40 separate column locations. The flip point is the fraction of columns per query: few columns over many rows → columnar wins by ~N/k; whole rows a few at a time → the row store’s locality wins. That single ratio is why the same data often lives in both.
The picture: the same three orders, stored two ways
Cost and trade-offs, operation by operation
The same 50 million orders, with 40 columns of 8 bytes each. Here Time is the work the engine does and Space is the bytes it touches. The point lookup uses an illustrative B-tree fan-out of 300.
| Case | Time | Space | Why |
|---|---|---|---|
Row store: SUM(revenue) by region | A full scan of every page | 50M × 320 B = 16 GB | Reads 38 columns only to throw them away. |
| Column store: the same query | Scans two column files | 50M × 16 B = 0.8 GB, 20× less before compression | Only the referenced columns leave the disk. |
| Column store: a low-cardinality column | Dictionary-encoded scan | country as 10-byte strings is 500 MB; as 1-byte codes (under 256 values) it is 50 MB | 10× smaller on disk, so 10× fewer bytes to scan, and sorting adds run-length savings on top. |
| Row store: fetch order #4471 | A B-tree descent: log₃₀₀ 50M ≈ 3.1, so about 4 page reads | One row, stored in one place | This is the checkout path. Locality wins. |
| Column store: fetch order #4471 | One lookup in each of 40 column files | One value from each file, then stitched back into a row | Fine now and then. Ruinous at checkout rates. |
| Row store: insert one order | One page write plus index updates, in a transaction | A few pages and a log record | Exactly the job OLTP is built for, thousands of times a second. |
| Column store: insert one order | One write per column, or a new tiny file | At 1,000 single inserts a second, 86,400,000 tiny writes a day | Columnar engines want batches of thousands of rows. Load in bulk or in micro-batches. |
| Row store: a covering index on (region, revenue) | An index-only scan instead of a table scan | Roughly the two columns plus per-entry overhead | It rescues this one query, and every insert now pays to maintain it. Ten reports means ten extra indexes on the checkout table. |
| Row store: a read replica | The same full scan, on another machine | Still 16 GB | It protects the primary, not the query. On Postgres a long query on a standby can be cancelled, or can hold back replay, when the two conflict. |
| Row store: a nightly summary table | Reports read a few thousand pre-aggregated rows | Tiny reads, plus one heavy job a night | Fine for fixed reports. Every new question needs a new summary, and every answer is up to a day old. |
| Column store: update one field | Usually a delete marker plus a re-insert, or a segment rewritten | A whole compressed block to change one value | Warehouses favour append-only facts. Model changes as new rows. |
Read the table as pairs. Every row where the column store wins is a scan of a few columns over many rows. Every row where it loses touches one whole row, or writes a little at a time. Nothing about hardware changes that pairing; it comes from the layout alone. That is why “a bigger Postgres box” postpones the problem and a pipeline to a warehouse solves it. The middle three rows are the usual stopgaps teams try first. Each one buys time for a known set of reports, and each one stops working the day an analyst asks a question nobody planned for.
Common mistakes with OLTP and OLAP
- SELECT * on the warehouse
A columnar store is only fast because it skips columns, and
SELECT *asks for all of them. On the numbers above that is 16 GB instead of 0.8 GB. Where billing is per byte scanned, as on BigQuery’s on-demand pricing, you pay for every column, andLIMIT 10does not reduce the bytes billed. Name the columns, and check the bytes-scanned estimate before you run something heavy. - Inserting into the warehouse one row at a time
Pointing the app’s per-order writes at a columnar store creates a tiny file or part per insert, and merging them falls behind. Write to OLTP, then load the warehouse in batches through CDC or ETL. If you need it fresher, use micro-batches every few seconds, not single rows. The warehouse does not need every order the instant it happens; it needs all of them, in order, without gaps.
- Copying the normalized schema one-to-one
A schema in third normal form is right for consistent writes. Copied unchanged into the warehouse, every dashboard becomes a join of eight tables. Model a star instead: one wide fact table (an order line with its amounts) and small dimension tables (product, customer, date) that it joins to once. The denormalized copy repeats data on purpose, because in a warehouse reads vastly outnumber writes.
- No partition or sort key on time
Most analytics asks about a time range. Without partitioning or clustering on the date, “yesterday’s revenue” scans three years. With it, the engine reads 1 day in 1,095, about 0.73 MB of the 0.8 GB two-column scan. Pick the key your filters actually use. Partitioning on a column nobody filters by costs you small files and buys nothing.
- Treating the warehouse as the live truth
The warehouse is a copy, always somewhat behind: seconds for a streaming CDC pipeline, a day for a nightly batch load. Do not check stock or balances against it. And make sure the pipeline carries updates and deletes, not just inserts, or cancelled orders keep counting as revenue. Reconcile a daily total between the two systems, so drift shows up as a number, not as a surprise in a board meeting.
Which would you pick?
Three situations. Pick the side you'd actually build — the explanation follows.
Analysts run a query summing a metric across two years of rows and it is timing out on the production database.
Row stores fetch whole rows even when a query touches two columns, so a two-year aggregate reads far more than it needs — an index does not change that. A replica moves the load off the primary without making the query any better suited to the engine. A columnar store reads only the columns involved, which is a difference in kind, not degree.
A checkout writing an order, a payment and three line items, which must all commit or none.
This is many small writes needing atomicity, which is exactly what a row-store transactional engine is built for. Analytical stores optimise for scanning large volumes and typically have weak or batch-oriented write paths — high volume is not the same property as high write concurrency. Splitting the transaction across two systems abandons the all-or-nothing guarantee.
Someone proposes pointing the BI tool straight at the production OLTP database "to keep it simple."
Long scanning queries and short latency-sensitive transactions contend for the same buffers, CPU and locks, so an ad-hoc analytical query becomes a customer-visible incident. A read-only user prevents writes, not resource contention — the risk is the query's cost, not its permissions.
Quick answers
OLTP or OLAP — which should I use?
Use OLTP (Postgres, MySQL) to power your live application’s individual reads and writes. Use OLAP (Snowflake, BigQuery, ClickHouse) for dashboards, reporting, and aggregate analysis over historical data. Most companies run both, connected by a CDC or ETL pipeline.
Why can’t I just run analytics on my production database?
A production OLTP database is row-oriented, meaning a heavy aggregate query has to read every column of every row just to touch the one field it needs — wasteful I/O that competes with, and can degrade, the live transactional workload the application depends on.
What makes column storage faster for analytics?
It stores each column contiguously instead of each row, so an aggregate query over one column reads only that column’s bytes across all rows, skipping everything else — and similar values stored together also compress far better than a mixed row.
How does data get from OLTP into OLAP?
Typically via a CDC (change data capture) or ETL pipeline that continuously or periodically replicates changes from the production database into the analytical warehouse, keeping analytics fresh without querying the live system directly.
OLTP vs OLAP: store it by rows, or by columns
Explore the topic
See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.
More Handbooks
- Concurrency, Locks & Isolation LevelsHow overlapping operations stay correct — race conditions, optimistic vs pessimistic locking, the four isolation levels and their anomalies, MVCC, and distributed locks with fencing tokens. Part of System Design Fundamentals.Read →
- Partitioning, Sharding & ReplicationHow one dataset becomes many — range vs hash partitioning, consistent hashing and virtual nodes, hot partitions, replication topologies, replication lag, and quorums. Part of System Design Fundamentals.Read →
- The SQL HandbookWhat the database does underneath your SELECT — the relational model and keys, joins (inner/left/right/full), indexes and B-trees, the query planner and reading EXPLAIN, transactions and ACID, isolation levels and the anomalies they prevent, normalization vs denormalization, and the pitfalls (N+1, missing indexes, SELECT *).Read →
- The PostgreSQL Internals HandbookUPDATE never updates, and a janitor keeps it working. Heap pages and tuples, MVCC's row versions (xmin/xmax visibility arithmetic), VACUUM, bloat and the wraparound scare, B-trees, HOT updates and index-only scans, the WAL's three superpowers (recovery, replication, PITR), reading the planner honestly, and why PgBouncer is infrastructure.Read →
- SQL vs NoSQLFramed as a war, it’s really a menu. Relational databases give you schema, joins and ACID; NoSQL is an umbrella of document/key-value/wide-column/graph stores that drop some of that for flexibility and horizontal scale. The relationships-vs-scale core difference, the CAP trade-off, and why to start relational.Read →
- PostgreSQL vs MySQLBoth are excellent free relational databases you can build a company on, so the choice is about character, not capability: Postgres prizes correctness, rich types and advanced features; MySQL prizes simplicity and read-heavy speed. The real differences, when each wins, and why Postgres became the modern default.Read →