Side by side
| Dimension | OLTP | OLAP |
|---|---|---|
| Primary job | Serve application transactions | Analyze data across many records |
| Query shape | Selective lookups and small updates | Large scans, joins, and aggregations |
| Write pattern | Frequent inserts, updates, and deletes | Often bulk or streaming ingestion |
| Typical storage layout | Row-oriented, with selective indexes | Column-oriented, with compression and pruning |
| Data modeling | Often normalized around business entities | Often facts, dimensions, and derived aggregates |
| Correctness focus | Atomic state changes and concurrency control | Accurate aggregates and consistent data snapshots |
| Freshness | Current operational state, subject to read guarantees | Depends on ingestion and transformation lag |
| Performance goal | Predictable latency under concurrent requests | Efficient processing of large data volumes |
| Scaling pressure | Contention, hot keys, connections, and write capacity | Scan volume, joins, memory, and concurrent queries |
The differences that matter
The distinction is workload, not SQL versus NoSQL. Reading one order by ID is an OLTP-style query even though it performs no write. Grouping a year of orders by product and region is OLAP-style work even if both queries use SQL and run on the same database.
Storage layout changes how much work a query performs. A row store can retrieve an order's fields together and use indexes for selective access. A column store can read only the columns needed for an aggregate, compress repeated values, and skip irrelevant blocks. Neither layout is universally faster; selectivity, update patterns, and physical design matter.
Separating workloads protects application latency. A report scanning a large order history can compete with checkout for CPU, memory, and I/O. A read replica may be enough for modest reporting, but it does not automatically provide columnar execution or eliminate replication lag.
Using both creates a data correctness boundary. A common design captures committed OLTP changes and sends them to an analytical store. You must define acceptable lag, handle duplicate events and deletes, and plan snapshot loading, replay, and schema changes. OLAP systems can support transactions, but a delayed analytical copy should not authorize an inventory reservation or money movement.
Choose OLTP when
- You need atomic updates to operational state, such as reserving inventory or recording balanced ledger entries.
- Most requests retrieve or modify a small number of records using known keys or selective indexes.
- User-facing requests need predictable latency despite many concurrent reads and writes.
- Reporting is small and infrequent enough that indexed queries or precomputed summaries meet requirements without a separate analytical platform.
Choose OLAP when
- Queries scan substantial history and aggregate across many customers, products, tenants, or time periods.
- Analysts need flexible grouping and joins that cannot all be anticipated with transactional indexes.
- Dashboards and reports need independent compute capacity so they do not disrupt operational traffic.
- You can define an acceptable freshness window and maintain an ingestion pipeline, including corrections and backfills.
A worked example
Checkout and revenue reporting need different paths
Suppose a ticketing service handles 2,000 reservation attempts per second during a sale and retains 200 million historical order records. Each reservation must atomically claim a seat and create an order; a daily revenue report groups completed orders by venue and event. Keep seat ownership and order transitions in the OLTP database. Capture committed order changes into an OLAP store for reporting, with a stated freshness target of five minutes. The report can scan history without competing directly with reservation transactions. If ingestion falls behind, show the report's last processed timestamp rather than implying it is current. Never use the delayed report to decide whether a seat is available.
In the interview
- Start with two representative queries and the records each touches. Contrast an order update by primary key with a revenue aggregation across months of orders, rather than choosing from product labels.
- State separate latency and freshness requirements. An analyst may accept a slower query over fresh data, while a dashboard may need fast queries over slightly delayed aggregates.
- Explain the evolution path: begin with one database when appropriate, then add summaries, replicas, or a separate analytical store when measured workload pressure justifies the complexity.
- If you introduce change data capture, expect questions about initial snapshots, duplicate delivery, ordering, deletes, schema evolution, and recovery after the consumer falls behind. Identify which store remains authoritative for business decisions.
Common mistakes
- Equating OLTP with writes and OLAP with reads. OLTP includes selective reads; OLAP systems also ingest data and apply corrections.
- Claiming OLAP means eventual consistency or no transactions. Workload type, transaction support, isolation, and pipeline freshness are separate properties.
- Sending unrestricted analytical queries to the transactional primary without discussing resource isolation or effects on request latency.
- Adding two databases without defining how changes propagate, how lag is measured, and how missed or duplicated changes are repaired.
Where it comes up
Interview questions where choosing between OLTP and OLAP comes up.
- Design Google AnalyticsEvent exploration and historical aggregates need analytical access patterns distinct from small transactional updates to account and site configuration.
- Design an ad click aggregatorLarge event aggregations and billing reconciliation require separating analytical counts from authoritative financial state.
- Design a ticket booking system like TicketmasterSeat reservations require atomic operational updates, while historical sales reports should not compete with the booking path.
- Design an A/B testing platformExperiment configuration needs operational access, while exposure-to-outcome analysis requires large joins and aggregations over collected events.
Questions people ask
What is the main difference between OLTP and OLAP?
OLTP optimizes small, concurrent operations on application state, while OLAP optimizes queries that examine and aggregate many records. The distinction concerns access patterns and performance goals, not whether the system uses SQL.
Can one database handle both OLTP and OLAP?
Yes, especially when data volume and analytical demand are modest. Some databases also offer hybrid transactional and analytical processing capabilities. Check workload isolation, data freshness, and performance under concurrent load before assuming one system meets both sets of requirements.
How do you move data from OLTP to OLAP?
Common approaches include scheduled extraction and change data capture from the source database's change log. Batch extraction can be simpler when delayed results are acceptable, while CDC can reduce freshness lag. Both require plans for initial loading, retries, deletes, schema changes, and reconciliation.