Cloud SQL Databases & Analytical Engines (Snowflake, BigQuery, DuckDB)
Compare cloud OLTP and OLAP engines and when to use each SQL dialect.
In plain words
Apps use one kind of database for quick single changes, and analysts use another kind built to add up huge amounts of data quickly.
Think of it like…
A shop's till versus its accounts office: the till (OLTP) handles one sale at a time, instantly, all day. The accounts office (the warehouse) adds up months of sales in bulk. DuckDB is a calculator on your own desk for the spreadsheets you brought home.
Where you’ve seen it
A startup's dashboards ran directly on its RDS PostgreSQL primary, and month-end reports slowed checkout. They now replicate tables to BigQuery nightly with an ELT tool, partition the events table by day and cluster it by customer_id, and point the BI tool at BigQuery. Checkout latency recovers, and a monthly report that scanned 2 TB now scans 40 GB because it filters on the partition column.
Words you’ll hear
- OLTP vs OLAP
- Many small reads and writes for apps vs large scans and aggregates for analysis.
- Columnar storage
- Stores each column separately, so queries read only the columns they use.
- Separated storage and compute
- Snowflake and BigQuery scale query power independently of stored data.
- Partition pruning
- Skipping partitions (such as days) that a filter rules out, so fewer bytes are scanned.
Visual diagram
Theory & example queries
Managed OLTP vs analytical engines
Managed OLTP services run the same engine you'd run yourself, so SQL, indexes and EXPLAIN work as usual; what you buy is automated backups and point-in-time restore, replicas, failover, patching and storage growth. Aurora and AlloyDB add redesigned storage layers for faster failover and more replicas. They're the right home for application data, but large analytical scans compete with user traffic for CPU, memory and I/O.
Warehouses are built the other way round. Columnar storage reads only the columns a query names and compresses them heavily; massively parallel execution splits scans across many workers. They're poor at single-row updates and high-concurrency point lookups, and excellent at "revenue by region by month over three years". Data reaches them through batch ELT tools or change data capture (CDC) from the OLTP database's log.
SELECT country, COUNT(*) AS signupsFROM read_parquet ('exports/users/*.parquet')WHERE signup_date >= DATE '2026-01-01'GROUP BY countryORDER BY signups DESC;PostgreSQL is the lesson baseline unless noted otherwise.
Calculate the selected expressions and return the requested output columns.
Expected output3 sample rows
| country | signups |
|---|---|
| India | 18420 |
| United States | 12650 |
| Germany | 8790 |
Note: Illustrative counts from the matched Parquet files; the glob and column values determine the real result.
No server, no load step; DuckDB reads only the needed columns from the Parquet files.
Key takeaway: OLTP for the app, columnar warehouse for analytics, DuckDB for local files.
Cost models and keeping queries cheap
BigQuery on-demand pricing charges by bytes scanned (capacity pricing with slots is the alternative). SELECT * reads every column, and LIMIT doesn't reduce bytes read on an unclustered table, so select only the columns you need, partition large tables by date, cluster by common filter columns, set require_partition_filter on big tables, and check the estimate with a dry run before running. Snowflake charges credits for the time a virtual warehouse runs (per second, with a 60-second minimum); each size step up doubles credits per hour. Set auto-suspend, size warehouses to the workload, and separate ETL from BI warehouses.
Both engines cache results of identical queries for about 24 hours, so repeated dashboard refreshes can be free. Dialects differ in details: Snowflake, BigQuery and DuckDB support QUALIFY to filter window-function results directly, BigQuery quotes identifiers with backticks, and date functions vary, so keep marts simple and test queries on the target engine.
| id | customer_id | status | amount | coupon_code |
|---|---|---|---|---|
| 101 | 1 | paid | 249 | NULL |
| 102 | 2 | paid | 120 | WELCOME10 |
| 103 | 1 | shipped | 89.5 | NULL |
SELECT customer_id, SUM(amount) AS revenueFROM shop.ordersWHERE order_date BETWEEN '2026-11-01' AND '2026-11-30'GROUP BY customer_id;PostgreSQL is the lesson baseline unless noted otherwise.
Calculate the selected expressions and return the requested output columns.
Expected output3 sample rows
| customer_id | revenue |
|---|---|
| 1042 | 24500 |
| 2087 | 18250 |
| 3114 | 9900 |
Note: Representative customer totals for the one-month partition pruned by the query.
On a table partitioned by order_date, this scans one month of two columns instead of every column for all time.
Key takeaway: BigQuery: scan fewer bytes. Snowflake: run warehouses for less time.
How it works, step by step
Follow one practical SQL workflow from start to finish. Select any step or play through the flow.
Classify the workload
Single-row reads and writes for an app → OLTP; large scans and aggregates → warehouse; files on a laptop or in CI → DuckDB.
checkout = OLTP · monthly revenue = OLAP
When to use it & trade-offs
What it is
Cloud SQL engines fall into two families. Managed OLTP databases (Amazon RDS and Aurora, Google Cloud SQL and AlloyDB, Azure SQL, Neon, Supabase) run PostgreSQL, MySQL or SQL Server for applications, with backups and failover handled for you. Analytical engines (Snowflake, BigQuery, Redshift) store data in columns and spread queries across many machines for scans over billions of rows. DuckDB is the odd one out: an analytical engine that runs inside your process, ideal for Parquet and CSV files on a laptop or in a pipeline.
Why it matters: Most companies run both families: the app on a managed OLTP database and reporting in a warehouse, connected by an ELT or CDC pipeline. Analysts and data engineers need to know how each engine charges (by compute time or bytes scanned), how to keep queries cheap, and which engine fits a job. Interviews ask "why not just run the dashboards on Postgres?" and "how would you cut our BigQuery bill?"
When to reach for it
- A warehouse for dashboards instead of the app's primary
- DuckDB for exploring exports and Parquet files
- Managed OLTP to avoid running databases yourself
When to avoid or be careful
- Heavy reports on the OLTP primary
- SELECT * on large BigQuery tables
- Snowflake warehouses without auto-suspend
Managed OLTP vs cloud warehouse vs DuckDB
Strengths: Familiar engines; managed backups, replicas and failover.
Watch out: Large analytical scans hurt app performance.
Strengths: Columnar, distributed, scales on demand.
Watch out: Costs grow with careless queries; not for app transactions.
Strengths: No server; very fast on one machine; reads Parquet and CSV directly.
Watch out: Single machine; not a shared, multi-user warehouse.
Interview signals & numbers to know
When this topic comes up
- “Why not run analytics on our Postgres?”
- “Our BigQuery bill doubled”
- “Snowflake or BigQuery?”
- OLTP vs OLAP
- DuckDB for local analysis
Benchmarks & rules of thumb
- ~24 h
- result cache lifetime in Snowflake and BigQuery
- 60 s
- Snowflake's minimum billing per warehouse start
- 2×
- credits per hour for each Snowflake size step
Common mistakes & follow-ups
Common interview mistakes
- Pointing the BI tool at the production primary, so month-end dashboards slow down checkout.
- Running SELECT * … LIMIT 10 on a 5 TB BigQuery table and paying to scan all of it.
- Leaving a large Snowflake warehouse running all night for a dashboard that refreshes once an hour.
Likely interviewer follow-ups
- Why shouldn't dashboards query the application database directly?
- How would you reduce the cost of BigQuery queries?
- When would you use DuckDB instead of a warehouse?
Knowledge check
Put it into practice
Practice related interview Q&A
Apply Cloud SQL Databases & Analytical Engines (Snowflake, BigQuery, DuckDB) with hands-on SQL practice and interview Q&A.