Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Engineering~8 min readComparison
Head to Head

OLTP vs OLAP: row store, or column store?

OLTPvsOLAP

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.

01

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.

→ The rule

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.

02

Head to head

DimensionOLTPOLAP
Query shapeSimple, touches few rows — "get this user’s cart"Complex, scans/aggregates millions of rows
Storage layoutRow-oriented — a full row read is cheapColumn-oriented — reading one column is cheap
SchemaNormalized, minimizes redundancy for consistent writesDenormalized star/snowflake, optimized for read speed
Write patternFrequent small writes, needs ACID transactionsBulk loads / periodic ETL, batched not per-transaction
ConcurrencyMany concurrent users, row-level lockingFewer concurrent analysts, but each query is huge
ExamplesPostgres, MySQL powering an appSnowflake, BigQuery, ClickHouse, Redshift
Latency expectationMillisecondsSeconds to minutes is normal for a heavy query
03

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
04

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.

→ The reason they’re separated

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.

05

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.

→ The trade you’re actually making

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.

06

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.

→ The pattern generalizes

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.

→ The number

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 picture: the same three orders, stored two ways

row store: one block per row column store: one file per column #4471 03-02 toys EU 19.99 #4472 03-02 books US 8.50 #4473 03-03 toys EU 42.00 id447144724473 date03-0203-03 cattoysbooks regionEUUSEU rev19.998.5042.00 reads all 40 columns: 16 GB reads 2 of 40: 0.8 GB SUM(revenue) GROUP BY region, 50M orders
Only five of the 40 columns are drawn, and repeated values are left blank. The row store keeps each order together, so the aggregate drags every column of every row off disk. The column store keeps each column together, so it opens two files and skips the rest. The sizes assume 40 columns of 8 bytes each across the page’s 50 million orders: 320 bytes a row, 16 GB in all, and 0.8 GB for two columns, the 20× from the flip-point section. Turn the query around, “show me order #4472”, and the picture flips: the row store reads one block, while the column store has to visit all five files, and 40 in the real table, to rebuild one row.
Trade-offs

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.

CaseTimeSpaceWhy
Row store: SUM(revenue) by regionA full scan of every page50M × 320 B = 16 GBReads 38 columns only to throw them away.
Column store: the same queryScans two column files50M × 16 B = 0.8 GB, 20× less before compressionOnly the referenced columns leave the disk.
Column store: a low-cardinality columnDictionary-encoded scancountry as 10-byte strings is 500 MB; as 1-byte codes (under 256 values) it is 50 MB10× smaller on disk, so 10× fewer bytes to scan, and sorting adds run-length savings on top.
Row store: fetch order #4471A B-tree descent: log₃₀₀ 50M ≈ 3.1, so about 4 page readsOne row, stored in one placeThis is the checkout path. Locality wins.
Column store: fetch order #4471One lookup in each of 40 column filesOne value from each file, then stitched back into a rowFine now and then. Ruinous at checkout rates.
Row store: insert one orderOne page write plus index updates, in a transactionA few pages and a log recordExactly the job OLTP is built for, thousands of times a second.
Column store: insert one orderOne write per column, or a new tiny fileAt 1,000 single inserts a second, 86,400,000 tiny writes a dayColumnar 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 scanRoughly the two columns plus per-entry overheadIt 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 replicaThe same full scan, on another machineStill 16 GBIt 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 tableReports read a few thousand pre-aggregated rowsTiny reads, plus one heavy job a nightFine for fixed reports. Every new question needs a new summary, and every answer is up to a day old.
Column store: update one fieldUsually a delete marker plus a re-insert, or a segment rewrittenA whole compressed block to change one valueWarehouses 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.

Watch 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, and LIMIT 10 does 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.

Your call

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.

A checkout writing an order, a payment and three line items, which must all commit or none.

Someone proposes pointing the BI tool straight at the production OLTP database "to keep it simple."

Frequently asked

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.

▶  Watch it explained

OLTP vs OLAP: store it by rows, or by columns

OLTP vs OLAP · Vibe Engines · 2026
Finished this one? 0 / 209 Handbooks done
NextOptimistic vs Pessimistic Locking Next on the “Data, and where it lives” ladder · rung 6 of 9

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks