Quick revision
The short answer
OLTP workloads are many short transactions that read or change a few rows by key, at high concurrency and with millisecond latency, on a normalized schema, such as inserting an order. OLAP workloads are fewer, large queries that scan and aggregate millions of rows on denormalized star schemas, where seconds or minutes are acceptable, such as revenue by region and month for three years. OLTP runs on databases like PostgreSQL and MySQL, OLAP on columnar engines like Snowflake, BigQuery or ClickHouse, and data moves between them through ETL or CDC.
What to remember
In this answer, we compared OLTP and OLAP. OLTP is many short, concurrent transactions on a few rows by key, with millisecond latency and a normalized schema, served by row stores such as PostgreSQL, MySQL and Oracle. OLAP is fewer large scans and aggregations on a star or snowflake schema, where seconds or minutes are fine, served by columnar engines such as Snowflake, BigQuery, Redshift, ClickHouse and DuckDB. Mixing them on one database hurts user latency, so we move data from OLTP to OLAP with ETL or CDC.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
OLTP workloads are many short transactions that read or change a few rows by key, at high concurrency and with millisecond latency, on a normalized schema, such as inserting an order. OLAP workloads are fewer, large queries that scan and aggregate millions of rows on denormalized star schemas, where seconds or minutes are acceptable, such as revenue by region and month for three years. OLTP runs on databases like PostgreSQL and MySQL, OLAP on columnar engines like Snowflake, BigQuery or ClickHouse, and data moves between them through ETL or CDC.
Why this question is asked
Almost every backend engineer works on an OLTP system, and almost every company eventually wants reports from that same data. Problems start when the two kinds of work share one database. Interviewers ask this question to check that we can tell the workloads apart, explain why they need different storage designs, and recognise when an analytics query is about to hurt users. In this answer, we will define both workloads, compare them on queries, data model, concurrency and latency, look at the databases built for each, and see how data flows from one to the other.
1What OLTP Means
OLTP stands for online transaction processing. It is the work our applications do while users wait: create an order, add an item to a cart, update a delivery address, read one customer's account. Each transaction touches a handful of rows, usually found through a primary key or another index, and finishes in a few milliseconds.
Because thousands of users do this at once, the database must handle high concurrency safely. It needs row-level locks, MVCC so readers do not block writers, and a write-ahead log for durability. The schema is normalized, which means each fact is stored once (a customer's email lives in the customers table, not copied into every order) so that an update changes exactly one row.
2What OLAP Means
OLAP stands for online analytical processing. Here the user is an analyst or a dashboard asking questions about the business: revenue by region and month for three years, the conversion rate per marketing channel, the top 100 products last quarter. Each query reads millions or billions of rows but only a few columns, and groups and aggregates them.
There are fewer of these queries, perhaps dozens per minute instead of thousands per second, and a response in a few seconds or even minutes is acceptable. The data model is usually denormalized into a star schema: one large fact table (one row per sale) surrounded by dimension tables (date, region, product). A snowflake schema is the same idea with the dimensions normalized a little further. Denormalizing saves joins at query time, and the duplication is acceptable because analytical data is loaded in batches rather than edited row by row.
3Comparing the Two Side by Side
The differences all follow from one thing: OLTP touches few rows many times, OLAP touches many rows few times. That is why OLTP engines store whole rows together (one read fetches a full order) while OLAP engines store each column separately and compress it (a sum over one column reads only that column).
| Aspect | OLTP | OLAP |
|---|---|---|
| Typical query | insert an order, read a cart by id | revenue by region and month, 3 years |
| Rows per query | 1 to a few hundred | millions to billions |
| Concurrency | thousands of transactions per second | tens of queries at a time |
| Latency target | milliseconds | seconds to minutes |
| Data model | normalized tables | star or snowflake schema |
| Writes | constant small updates | bulk loads, appends |
| Storage layout | row store, B-tree indexes | column store, compression |
| Example engines | PostgreSQL, MySQL, Oracle | Snowflake, BigQuery, Redshift, ClickHouse, DuckDB |
Notice the last row of the table. The two workloads are tuned for opposite access patterns, so a database that is excellent at one is usually mediocre at the other.
4Why Running OLAP on the OLTP Database Hurts
It is tempting to point the reporting tool at the production PostgreSQL, because the data is already there. The trouble is that both workloads compete for the same CPU, memory and disk. A query that scans 900 million rows pushes the hot pages that user requests need out of shared buffers and the operating system cache, saturates disk bandwidth, and keeps CPU cores busy for minutes. User-facing requests that used to take 2 ms start taking 50 ms.
There is also a quieter cost in PostgreSQL. A long-running query holds an old snapshot, and while it runs, vacuum cannot remove row versions that the snapshot might still need, so busy tables bloat. So even a single long report can make the whole database slower for hours.
5How Data Moves From OLTP to OLAP
The usual design keeps each workload on the engine built for it and copies data from one to the other. In ETL (extract, transform, load), a scheduled job extracts changed rows, reshapes them into the star schema and loads them into the warehouse, typically every hour or every night. In CDC (change data capture), a tool such as Debezium reads the OLTP database's change log (the WAL in PostgreSQL, the binlog in MySQL) and streams every insert, update and delete, often through Kafka, so the warehouse is only minutes behind.
- Application writes to PostgreSQLshort transactions, normalized tables
- CDC reads the WAL, or ETL extracts changesDebezium and Kafka, or a scheduled job
- Load into a columnar warehouseSnowflake, BigQuery, ClickHouse
- Model into fact and dimension tablesstar schema, for example with dbt
- Dashboards and analysts query the warehousethe OLTP database never sees these scans
5 steps in order. Play them, or step through them one at a time.
The choice between them is mostly about freshness and effort. A nightly batch is simple and is enough for monthly reports. CDC costs more to run but gives near-real-time dashboards and does not put heavy extract queries on the source.
6Follow-up questions
What is HTAP and when does it help?
HTAP means hybrid transactional and analytical processing: one system that serves both workloads, usually by keeping a row-oriented copy for transactions and a column-oriented copy for analytics that it updates automatically. Examples include TiDB with TiFlash and SingleStore, and some cloud databases offer a columnar replica of an OLTP store. It helps when we need analytics on data that is seconds old and want to avoid running a separate pipeline. The cost is a more complex, often proprietary system, and very large historical analytics usually still belong in a warehouse.
Is a read replica enough to separate the workloads?
It moves the load off the primary, which is a good first step, but the replica is still a row store with the same slow scans. In PostgreSQL, long queries on a hot standby can also be cancelled by WAL replay, or, with hot_standby_feedback on, they cause bloat back on the primary.
Can PostgreSQL do OLAP at all?
For moderate volumes, yes: with partitioning, parallel query, BRIN indexes and summary tables it handles tens of millions of rows well. Columnar extensions extend this further. Beyond that, a dedicated columnar engine is usually cheaper and much faster.
7Conclusion
In this answer, we compared OLTP and OLAP. OLTP is many short, concurrent transactions on a few rows by key, with millisecond latency and a normalized schema, served by row stores such as PostgreSQL, MySQL and Oracle. OLAP is fewer large scans and aggregations on a star or snowflake schema, where seconds or minutes are fine, served by columnar engines such as Snowflake, BigQuery, Redshift, ClickHouse and DuckDB. Mixing them on one database hurts user latency, so we move data from OLTP to OLAP with ETL or CDC.
Open with
OLTP is the work our applications do while users wait: many short transactions that touch a few rows by key, like inserting an order or reading a customer's cart.
Then, if they want more
It needs high concurrency and millisecond latency, uses a normalized schema so each fact is stored once, and runs on row stores like PostgreSQL, MySQL or Oracle. OLAP is analytics: fewer, much larger queries that scan and aggregate millions of rows, like revenue by region and month for the last three years.
Seconds or minutes are acceptable, the schema is usually a denormalized star or snowflake, and it runs best on columnar engines like Snowflake, BigQuery, Redshift, ClickHouse or DuckDB, because they read only the columns a query needs and compress them.
I would not run heavy OLAP queries on the OLTP database, because they compete for CPU, memory and I/O, evict hot pages from cache and, in PostgreSQL, hold back vacuum, so user-facing latency suffers.
Instead, data moves from the OLTP side to the warehouse, either with a scheduled ETL job or with CDC, for example Debezium reading the WAL into Kafka, depending on how fresh the reports need to be.
About this answer
- Last updated
- 12 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- PostgreSQL documentation, MySQL reference manual
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Compare OLTP and OLAP workloads: typical queries, data model, concurrency, latency and...": https://scrivio-interview-library.netlify.app/databases/storage-internals/9056bde962/