Advanced Topic 47 of 51 Databases
OLTP vs OLAP
Transaction-heavy versus analysis-heavy workloads.
How it works
OLTP, online transaction processing, handles many short transactions that read and write a few rows, such as placing an order, with high concurrency, normalized schemas, row-oriented storage and strict ACID guarantees. OLAP, online analytical processing, runs complex queries that scan and aggregate large volumes of historical data, often over denormalized or star schemas with column-oriented storage and relaxed update patterns. The two have opposite workloads and optimizations.
Step-by-step walkthrough
- OLTP handles many small transactions, such as orders.
- It favors row storage and indexes.
- OLAP handles few large analytical queries.
- It favors column storage and compression.
- Warehouses are tuned for OLAP, production databases for OLTP.
Where it is used
Operational applications run on OLTP databases such as PostgreSQL and MySQL, while analytics runs on OLAP systems such as warehouses, ClickHouse and Druid, fed by data pipelines.
Common pitfall
Running heavy analytics on the OLTP database slows the application and risks locking. Duplicating data adds lag, so analytics may be slightly stale. Hybrid HTAP systems try to serve both, with trade-offs. Separate workloads, use replicas or change data capture, and choose storage layout to match the access pattern.
Where it fits in the course
OLTP vs OLAP is topic 47 of 51 in Databases, rated Advanced. It follows Data Warehousing. The next topic is LSM Trees.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Databases quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Databases quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is OLTP vs OLAP?
Where do people use OLTP vs OLAP?
What is the most common mistake with OLTP vs OLAP?
What should I learn before this topic?
How can I practice it?
Is OLTP vs OLAP hard to learn?
How long does it take to learn OLTP vs OLAP?
Which topics are related to OLTP vs OLAP?
What should I study after OLTP vs OLAP?
Related topics
- Data Warehousing (Databases)
- LSM Trees (Databases)
- Eventual Consistency (Databases)
- NewSQL and Distributed SQL (Databases)