OLTP vs OLAP Workloads
Learn why transactional and analytical systems are designed differently, from row vs columnar storage to query patterns and modeling goals.
Beginner · about 3 hours · difficulty 2/5
Learn first: SQL Fundamentals
Data modeling decisions depend on the workload. An app database and an analytics warehouse look similar (tables, SQL) but are built for opposite jobs.
OLTP: online transaction processing
- Many small reads and writes: place an order, update a wallet balance.
- Needs low latency, strong consistency and many concurrent users.
- Row-oriented storage and normalized schemas avoid duplicated data and update anomalies.
- Examples: PostgreSQL, MySQL, Oracle behind an app.
OLAP: online analytical processing
- Few, large queries that scan millions of rows but only a few columns: revenue by state by month.
- Writes happen in bulk loads.
- Columnar storage, compression and parallel execution make scans fast.
- Denormalized, dimensional schemas make queries simple for analysts.
- Examples: Snowflake, BigQuery, Redshift, ClickHouse, Databricks SQL.
Why columnar is faster for analytics
If a table has 100 columns and your query needs 3, a columnar engine reads roughly 3 percent of the data. Values in one column are similar, so they compress well. This is also why Parquet, a columnar file format, matters.
HTAP and real-time analytics
Some systems blur the line (real-time OLAP stores like ClickHouse or Apache Pinot for user-facing dashboards). Know they exist; the core distinction still guides design.
Pitfalls
- Running analytics directly on the production OLTP database.
- Copying the app's normalized schema into the warehouse unchanged and expecting analysts to join 15 tables.
You are ready to move on when you can explain, using a Zomato-style order example, why the same data is stored differently in the app database and the warehouse.
Key concepts
- OLTP characteristics
- OLAP characteristics
- Row vs columnar storage
- Normalized vs denormalized
- Real-time OLAP stores: ClickHouse, Pinot, Druid
Mini project
Load the same 5 million row dataset into PostgreSQL and DuckDB. Run an aggregate over three columns in each and compare runtime. Write a short note explaining the difference using row vs columnar storage.
Check yourself
Why does a columnar store make SELECT * expensive while making SELECT SUM(amount) cheap?
Free resources
- BigQuery overview (Google Cloud)
- DuckDB documentation (DuckDB)
- Data Engineering Zoomcamp (DataTalksClub)