Data Architecture & Reliability
Designing a Scalable Analytics Platform (Like Snowflake / BigQuery)
Storage and Compute Are Two Different Problems. Most Databases Solved Them Together. That Was the Mistake.

They won by separating storage, compute, metadata, and concurrency into independent systems.
TL;DR
- The core innovation of modern analytics platforms is separating storage from compute — enabling independent scaling of each
- The query optimizer does more work than the executors — a bad query plan is more expensive than a slow cluster
- Metadata — catalog lookups, partition statistics, file listings — becomes the bottleneck before compute does at scale
- Concurrency is solved through isolation, not contention management: independent compute clusters share storage without locking
- You are not building Snowflake — but understanding how it works changes how you design everything that touches analytical queries
Every query plan is a bet. The optimizer is making it. The data is settling it.
10,000 analysts. One data platform. All running queries simultaneously.
In a traditional data warehouse, they would compete. For CPU. For memory. For I/O bandwidth. The heavy query from the ML team would stall the dashboard refresh for the VP of Sales.
Snowflake solved this in 2012. Not by making the hardware faster. By asking a different question:
What if the storage layer and the compute layer had nothing to do with each other?
Modern analytics platforms — Snowflake, BigQuery, Redshift Spectrum, Databricks SQL — are built on a single architectural principle that was not obvious until someone built it: storage and compute are fundamentally different problems that should be solved by fundamentally different systems.
This blog is about understanding why that principle holds, how the query execution machinery is built on top of it, and where the real complexity lives — in the optimizer, the metadata layer, and the concurrency model.
The Problem That Created These Platforms
Traditional data warehouses like Teradata, Netezza, and early Redshift bundled storage and compute into the same nodes. Every node held data and ran queries against that data.
This design has one critical property: it is efficient when the cluster size matches the query workload exactly.
It has one critical failure mode: in practice, the cluster size never matches the workload exactly.
At 9 PM on a weekday, the cluster sits mostly idle. Storage is provisioned for petabytes of data. Compute is provisioned for the peak query load. You pay for both, all the time.
At 9 AM on the Monday after a product launch, every analyst runs their retrospective queries simultaneously. The cluster cannot scale horizontally — adding nodes requires rebalancing data across the cluster, which takes hours and means rewriting a significant portion of stored data.
The result is a system that is simultaneously over-provisioned for off-peak hours and under-provisioned for peak hours — and structurally unable to fix either problem quickly.
The Core Architectural Insight: Separate Storage from Compute
Why Coupled Architectures Break
In a coupled architecture, scaling compute means scaling storage. If you need twice the CPU power, you provision twice the nodes — which means twice the storage, even if your data hasn’t grown. If your data doubles, you provision more storage nodes — which means more compute, even if your query load hasn’t changed.
The two dimensions are locked together. Every cost optimization decision in one dimension has consequences in the other.
What Separation Actually Enables
When storage and compute are separated, they can scale and fail independently.
Storage (S3, GCS, ADLS) holds columnar files — Parquet or ORC — along with a metadata catalog that tracks file locations, partition boundaries, column statistics, and row group metadata. Storage is cheap, durable, and infinitely scalable. It does not run queries.
Compute clusters read from storage over the network, execute query fragments in memory, and return results. They hold no data permanently. When a query finishes, the compute cluster can be suspended — and you stop paying for it.
Traditional warehouse:
Storage + Compute (tied together)
Scale one → must scale both
Idle hours: you pay for both
Peak hours: bottlenecked by whichever you provisioned less of
Separated architecture:
Storage: always on, cheap, shared across all compute clusters
Compute: on-demand, independent, one per workload class
Idle hours: suspend compute, pay only for storage
Peak hours: spin up additional compute clusters in secondsThe economic model changes completely. Storage cost is flat and scales with data volume. Compute cost is variable and scales with query activity.
The Query Execution Path
When an analyst submits a SQL query, the path from text to result involves five distinct stages — each with its own failure modes and performance characteristics.
Parsing and Planning
The query coordinator receives the SQL string and compiles it into an execution plan.
Parsing converts SQL text into an abstract syntax tree. This is fast and rarely a bottleneck.
Planning converts the abstract syntax tree into a logical plan — a tree of relational operators (scans, joins, aggregations, projections). The logical plan is then optimized into a physical plan: which join algorithm to use, which filters to push down to storage, how many partitions to scan, whether to use a broadcast join or a sort-merge join.
The optimizer is where the most consequential decisions are made. A bad plan is almost never recoverable at execution time. An optimal plan on a slow cluster beats a bad plan on a fast cluster.
-- This query looks simple
SELECT
customer_id,
SUM(amount) as total_spend
FROM transactions t
JOIN customers c ON t.customer_id = c.id
WHERE t.transaction_date >= '2026-01-01'
AND c.country = 'IN'
GROUP BY customer_id
-- The optimizer must decide:
-- 1. Apply the date filter before or after the join?
-- 2. Apply the country filter before or after the join?
-- 3. Which table is the build side of the hash join?
-- 4. How many shuffle partitions for the GROUP BY?
-- 5. Can we push the date filter down to Parquet row group pruning?The correct answers depend on the data distribution — specifically, the cardinality of each filter, the size of each table, and the clustering of the physical files. All of this is encoded in statistics.
Distributed Execution
The physical plan is compiled into a directed acyclic graph (DAG) of stages. Each stage is a unit of distributed execution that can run in parallel across executors.
A typical analytical query over a large table might produce:
# The three exchange operators every analytics platform implements:
# 1. Broadcast exchange — small table copied to every node
# Used when: one side < broadcast threshold (default 10MB, tune to 200MB+)
# Cost: N copies of small table. Zero shuffle for large table.
spark.conf.set("spark.sql.autoBroadcastJoinThreshold", 200 * 1024 * 1024)
# 2. Repartition exchange — both sides shuffled by join key
# Used when: both sides too large for broadcast
# Cost: full shuffle of both tables. Dominant cost in most analytical queries.
# Spill behavior: when executor memory exhausted, writes to local disk
# Spill multiplier: 2-3x latency increase when shuffle spills
# 3. Sort-merge exchange — both sides sorted then merged
# Used when: data already sorted on join key (range partitioning)
# Cost: sort cost + merge pass. No hash table in memory.
# Advantage: bounded memory. No OOM risk.
# Adaptive Query Execution switches between these at runtime:
spark.conf.set("spark.sql.adaptive.enabled", "true")
# AQE observes actual partition sizes post-shuffle
# Converts SortMergeJoin → BroadcastHashJoin when one side collapses smallStage 1: Parallel scan
→ Each executor reads assigned Parquet files
→ Applies predicate pushdown to skip row groups
→ Returns filtered rows
Stage 2: Hash join
→ Small table (customers) is broadcast to all executors
→ Large table (transactions) is probed against the broadcast copy
→ No shuffle required for the join
Stage 3: Partial aggregation (map-side)
→ Each executor computes partial GROUP BY aggregates
→ Reduces shuffle volume for the final aggregation
Stage 4: Final aggregation (reduce-side)
→ Shuffle to co-locate matching customer_ids
→ Compute final SUM per customer_id
Stage 5: Result collection
→ Return to coordinator
→ Serialize and transmit to clientEach stage boundary is a synchronization point. All executors in Stage 1 must complete before Stage 2 begins. A single slow executor — due to data skew, network contention, or GC pressure — stalls the entire stage.
Vectorized Execution
Most query engines before 2015 processed data row-by-row. One row. Apply filter. Pass to next operator. Repeat.
Modern engines process data column-by-column, in batches of 1,024–8,192 values.
The difference:
- Row-at-a-time: one function call per row = billions of function calls
- Vectorized batch: one function call per 4,096 rows = millions of function calls
Apache Arrow is the in-memory columnar format that makes this possible. A column of integers is a contiguous array in memory. SIMD CPU instructions operate on 8–16 integers simultaneously. A single filter operation over 1M rows takes microseconds, not milliseconds.
This is why Photon (Databricks), Dremel (BigQuery), and Snowflake’s execution layer all use vectorized columnar execution. Row-at-a-time execution is not slower because of algorithmic differences. It is slower because it destroys CPU cache locality on every operator boundary.
Result Merging
The coordinator assembles partial results from all executors into a final result set. For queries returning large result sets, this step itself can be expensive. Most production analytics platforms materialize large results to object storage and return a pointer — the client fetches the result set independently, avoiding coordinator memory pressure.
The Query Optimizer: Where the Real Work Happens
The optimizer is the most intellectually complex component in an analytics platform. It operates on statistical estimates of data distribution and produces a plan that minimizes estimated cost.
The gap between the optimizer’s estimate and reality is where performance problems live.
Statistics and Cost Estimation
The optimizer relies on table statistics to estimate cardinalities — how many rows will survive each filter, how large each intermediate result will be, how much data will cross the network during a shuffle.
Without statistics, the optimizer makes worst-case assumptions. With stale or missing statistics, it makes wrong assumptions — often producing plans that are 10–100× slower than the optimal plan.
-- Force statistics collection on the tables your most expensive queries touch
ANALYZE TABLE transactions COMPUTE STATISTICS FOR ALL COLUMNS;
ANALYZE TABLE customers COMPUTE STATISTICS FOR ALL COLUMNS;
-- Inspect what the optimizer actually knows
DESCRIBE EXTENDED transactions;
-- Look for: numRows, rawDataSize, column stats (min, max, distinct count, null count)In Spark and Snowflake-style systems, statistics are collected at table creation time and after significant data changes. The most common production failure: statistics are never refreshed after a large data load, and the optimizer plans a query against a table that has grown 10× since statistics were last computed.
Predicate Pushdown
The most impactful single optimization in columnar query execution: filtering data at the storage layer before it enters the compute layer.
Parquet files store min/max statistics for every column in every row group. The query engine can compare query predicates against these statistics and skip row groups entirely — without reading any data — when the predicate cannot possibly match any row in the group.
Table: transactions (10 TB, 50,000 row groups)
Query predicate: transaction_date >= '2026-05-01'
Row group statistics:
Row group 1: transaction_date MIN=2024-01-01, MAX=2024-12-31 → SKIP
Row group 2: transaction_date MIN=2025-01-01, MAX=2025-06-30 → SKIP
...
Row group 47,832: transaction_date MIN=2026-04-28, MAX=2026-05-15 → READ
...
Result: 94% of data skipped before leaving storage.
Effective scan: 600 GB instead of 10 TB.Predicate pushdown effectiveness depends entirely on data clustering. If transaction_date is randomly distributed across row groups, every row group has an overlapping date range, and nothing is skipped. If transactions are written in date order — as they typically are in append-heavy pipelines — row groups have tight, non-overlapping date ranges, and pushdown is highly effective.
This is the mechanism behind Z-ordering and clustering: they reorganize physical data layout to maximize predicate pushdown effectiveness for the query patterns you care about.
Join Ordering
For queries with multiple joins, the order in which joins are applied determines how much data flows between stages. Joining the two largest tables first produces a large intermediate result that then gets filtered. Joining a large table with a highly selective filter first produces a small intermediate result.
The optimizer uses cardinality estimates to determine the optimal join order. When estimates are wrong — because statistics are stale or because a filter is correlated with another filter in a non-obvious way — the optimizer picks a suboptimal order.
-- Optimizer sees this
SELECT * FROM A JOIN B ON ... JOIN C ON ... WHERE C.status = 'active'
-- Wrong order (optimizer underestimates C's selectivity):
-- (A ⋈ B) → 80M rows → ⋈ C → 2M rows
-- Shuffles 80M rows across the network before applying the selective filter
-- Right order (optimizer correctly estimates C's selectivity):
-- C filtered → 2M rows → ⋈ A → ⋈ B
-- Shuffles only 2M rows through the join pipelineWhen you see a query that is significantly slower than expected, the join order is usually the first thing to investigate in the query plan.
The Metadata Layer
The catalog — the system that tracks which files exist, where they are, and what data they contain — is the component most engineers underestimate until it becomes the bottleneck.
Why Metadata Becomes the Bottleneck
At petabyte scale, a single table can have millions of Parquet files. Before executing any query, the optimizer must:
- List all files in the relevant partitions (S3 LIST request — sequential, not parallelized)
- Read the footer of each file to retrieve row group statistics (one GET request per file)
- Apply partition pruning to eliminate irrelevant partitions
- Apply file-level predicate pushdown to eliminate irrelevant files
- Construct the list of files to scan
Steps 1 and 2 are the bottleneck. At 1 million files, listing and reading footers takes minutes — before a single byte of actual data is read.
This is why metadata is not an afterthought in modern analytics platforms. It is a first-class system with its own latency SLOs, caching layers, and optimization strategies.
Partition Pruning at Query Time
Partition pruning is the metadata-layer equivalent of predicate pushdown. Instead of skipping row groups within a file, it skips entire partitions — and entire directories in object storage.
# Partition pruning in action
# Query: SELECT * FROM events WHERE event_date = '2026-05-01' AND region = 'south'
# Without partition pruning:
# Scan all partitions → list all files → read all files → filter in memory
# Cost: proportional to total table size
# With partition pruning (table partitioned by event_date and region):
# Prune to partition: s3://bucket/events/event_date=2026-05-01/region=south/
# Cost: proportional only to that partition's size
# In practice — inspect partition elimination in Spark
df.filter("event_date = '2026-05-01' AND region = 'south'") \
.explain(mode="formatted")
# Look for: PartitionFilters in the plan
# If missing: your query is doing a full table scan despite having a partition filter
Snowflake Micro-Partitions
Snowflake’s metadata scaling innovation is the micro-partition.
Every table is divided into micro-partitions: immutable, columnar files of
50–500MB compressed. Each micro-partition stores metadata about every column: min, max, distinct count, null count.
This metadata lives in Snowflake’s metadata store — not in the files themselves.
The consequence:
- Partition pruning requires zero file reads
- Predicate evaluation against column statistics is a pure metadata query
- 10 billion rows across 200,000 micro-partitions can be pruned in milliseconds before any storage I/O occurs
Compare this to Hive Metastore at 1M partitions:
- Listing partitions: sequential catalog scan, minutes
- Reading file statistics: one S3 HEAD per file, parallelized but still slow
- At 5M files: catalog enumeration dominates query latency
The micro-partition model decouples metadata scale from storage scale. That is why Snowflake can prune 10TB tables faster than a self-managed Spark cluster can list partitions on a 500GB table.
Concurrency Without Contention
The fundamental concurrency challenge in an analytics platform is that queries from different workloads have different resource requirements, different latency tolerances, and different priority levels — and they should not interfere with each other.
Virtual Warehouses / Compute Clusters
Snowflake’s virtual warehouse model — replicated independently in Databricks SQL’s serverless compute and BigQuery’s slot model — solves this by giving each workload class its own isolated compute cluster, all reading from the same shared storage.
Shared storage (S3):
└── Parquet files, metadata catalog, statistics
Compute cluster A (Analytics team):
- Running 50 dashboard queries
- Autoscaling 4–16 nodes
- Pauses at 10 PM, resumes at 8 AM
Compute cluster B (Data science team):
- Running 3 long-running ML feature jobs
- Fixed 32-node configuration
- Always on
Compute cluster C (ETL pipeline):
- Scheduled batch ingestion
- Spins up for 30 minutes, terminates on completion
- Costs nothing between runsCluster A’s heavy query load never affects Cluster B’s feature computation. Cluster C’s batch ingestion never stalls Cluster A’s dashboards. They compete for storage bandwidth — which is highly parallelized in object storage — but not for CPU or memory.
Result Caching
Result caching is the mechanism that makes analytics platforms feel faster than they are for repeated queries. When two analysts run the same query within a cache TTL window, the second analyst receives the cached result from the first execution — with sub-second latency, regardless of how expensive the query was to run.
The cache key is typically a hash of the normalized SQL plus the table versions accessed. When underlying tables are updated, the cache is invalidated automatically.
For dashboard use cases — where the same aggregation queries run on every page load — result caching can reduce compute costs by 60–80% and p50 query latency by 99%.
Materialized Views
For recurring analytical queries that are too expensive to run on demand but too important to leave to a 24-hour batch schedule, materialized views precompute and persist results:
-- Define a materialized view for the most common dashboard aggregation
CREATE MATERIALIZED VIEW daily_revenue_by_region
AUTO REFRESH = TRUE
AS
SELECT
transaction_date,
region,
SUM(amount) AS total_revenue,
COUNT(*) AS transaction_count,
COUNT(DISTINCT customer_id) AS unique_customers
FROM transactions
GROUP BY transaction_date, region;
-- Query the materialized view directly (sub-second for most date ranges)
SELECT * FROM daily_revenue_by_region
WHERE transaction_date >= DATEADD(day, -30, CURRENT_DATE())
ORDER BY transaction_date DESC, total_revenue DESC;The materialized view is refreshed incrementally as new data arrives — only recomputing the partitions affected by new writes. The query sees a precomputed result. The compute cost is amortized across all reads of that view.
The Caching Hierarchy
Modern analytics platforms maintain multiple caching layers, each optimized for different access patterns:

The local disk cache deserves particular attention. Snowflake calls it the “local disk cache” — each virtual warehouse node caches recently accessed Parquet files on local SSD. When the same tables are accessed repeatedly by the same cluster (common for dashboard workloads), the effective read latency drops from ~20ms (S3 object GET) to ~0.5ms (SSD read), and network bandwidth is eliminated entirely.
The implication for cluster configuration: for dashboard workloads with high query repetition over the same tables, a larger node with more local SSD is often more cost-effective than more nodes with less local storage.
Failure Modes at Scale
Query Planner Regressions
Stale statistics produce bad plans. Bad plans consume 10–100× the expected resources. At high query concurrency, one bad plan can saturate the entire cluster.
The failure is subtle: the query runs, it just runs slowly. The query coordinator has no mechanism to detect a bad plan in flight — it can only observe that a stage is taking longer than expected after it has already allocated the resources.
The mitigation is proactive statistics management — refresh statistics after large data loads, set alerts on queries that exceed expected resource consumption, and maintain a query performance baseline to detect regressions.
Hot Partitions and Data Skew
In Spark-based analytics platforms, data skew at the partition level produces the same problem it does in streaming: one executor processes 40% of the data while the rest finish and wait.
The detection mechanism is identical to streaming skew detection — look at stage-level task duration distribution in the Spark UI. If p99 task duration is 10× the median, you have skew.
# Salting for skewed groupBy in analytical queries
from pyspark.sql import functions as F
# Skewed: customer_id has a few high-frequency values
df.groupBy("customer_id").agg(F.sum("amount"))
# Salted: distribute high-frequency keys across artificial salt partitions
salt = 20
df_salted = df.withColumn("salt", (F.rand() * salt).cast("int"))
df_salted.groupBy("customer_id", "salt") \
.agg(F.sum("amount").alias("partial_sum")) \
.groupBy("customer_id") \
.agg(F.sum("partial_sum").alias("total"))Metadata Catalog Saturation
At petabyte scale with many small tables, the metadata catalog itself becomes a bottleneck. Catalog queries — listing partitions, reading statistics, resolving table locations — are sequential operations that do not scale with cluster size.
The mitigation: partition consolidation (fewer, larger partitions), file compaction (fewer, larger files), and catalog statistics caching at the compute layer. For tables with millions of partitions, consider whether the partitioning strategy can be simplified without sacrificing query performance.
Trade-offs
Separation of storage and compute vs network latency. Reading from object storage over a network introduces 10–30ms latency per file read vs microseconds for local disk. This is the fundamental cost of the architecture. It is mitigated by local disk caching, columnar compression (fewer bytes to read), and predicate pushdown (fewer files to read). For scan-heavy workloads with good clustering, the local cache hit rate often exceeds 90%, making the network penalty negligible in practice.
Result caching vs data freshness. Cached results are stale by definition. For dashboard queries where the underlying data changes continuously, the cache TTL must be tuned to balance freshness against compute cost. There is no universal answer. The right TTL depends on how frequently the underlying data changes and how much staleness is tolerable for the use case.
Materialized views vs storage cost. Materialized views persist precomputed results. They consume storage. For expensive queries that are queried frequently, the compute savings dominate. For queries that are run rarely, the storage cost of the materialized view may exceed its value. The breakeven depends on query frequency and per-query compute cost.
Cluster isolation vs storage bandwidth. Independent compute clusters eliminate CPU and memory contention. They do not eliminate storage bandwidth contention. At very high query concurrency from many isolated clusters, S3 bandwidth can become the bottleneck. Object storage supports very high aggregate throughput — but it is not infinite, and it is shared.
What You Are Actually Building vs What Snowflake Built
Snowflake spent a decade building the metadata layer, the optimizer, the result cache, the virtual warehouse autoscaling, and the cross-region failover. You are not building that.
What you are building — in practice — is a layered architecture that uses these platforms as execution engines and focuses engineering effort on the layers above and below them:
Above: query patterns, materialized view strategy, cluster configuration per workload class, statistics refresh cadence, result cache TTL tuning.
Below: data layout (partitioning, clustering, Z-ordering), file size enforcement, schema evolution governance, storage tiering.
The platform handles query execution. You handle the data architecture that makes query execution efficient.
The engineers who get the most out of analytics platforms are not the ones who understand every detail of the query optimizer. They are the ones who understand how their data’s physical layout affects the optimizer’s decisions — and design that layout accordingly.
Why internal analytics platforms consistently fail to match managed offerings comes down to one word: optimizer.
Distributed compute is a solved problem. Spark, Trino, Presto — pick one, configure it, it scales. The execution layer is not the moat.
The optimizer is the moat.
A query optimizer that has been trained on billions of query patterns, with statistics collected automatically, refreshed continuously, and stored in a purpose-built metadata system — that is a decade of engineering.
Internal platforms built on Hive Metastore with manual ANALYZE TABLE runs are competing against systems where statistics collection is invisible and always current.
The second moat: open table formats changed the economics but not the problem.
Delta Lake, Iceberg, and Hudi give you ACID transactions and time travel on object storage. They do not give you a query optimizer. They do not give you automatic micro-partitioning. They do not give you result caching with automatic invalidation.
The open table format is the foundation. The optimizer and the metadata engine are the building. Most internal platforms have the foundation. Almost none have the building.
Operational Lessons
Statistics freshness is a correctness concern, not a tuning concern. Stale statistics do not produce slightly suboptimal plans. They produce catastrophically wrong plans. Set up automated statistics refresh after every significant data load.
Cluster configuration should match workload characteristics. Dashboard queries are short, high-concurrency, and benefit from large result caches and fast autoscaling. ETL jobs are long, low-concurrency, and benefit from larger nodes with more memory. Data science workloads are unpredictable. Give each workload class its own cluster tuned for its characteristics.
The local disk cache is the most underutilized feature in most deployments. For workloads with high table reuse — the same dimension tables appearing in many queries — a cluster warm-up routine that pre-reads hot tables into the local cache reduces p99 query latency significantly.
Monitor query compilation time independently from execution time. In mature analytics platforms, query planning can take longer than execution for short queries against large catalogs. Planning time is invisible in most monitoring. Add it to your latency decomposition.
Final Takeaway
Analytics platforms like Snowflake and BigQuery did not win because they were faster than traditional warehouses.
They won because they asked a different question: what if storage and compute had different scaling laws, different cost curves, and different operational requirements — and what if the architecture reflected that?
The query optimizer, the metadata catalog, the caching hierarchy, and the virtual warehouse model are all consequences of that one insight.
📌 Core Principle
Every query plan is a bet the optimizer makes
against the current state of your data.
Bad statistics means the optimizer is betting blind.
The cluster pays for every wrong bet.Next in Series
Designing a Feature Store from Scratch
The analytics platform answers historical questions.
The feature store answers the question the model is asking right now.
Next, we break down the hardest problem in ML infrastructure: keeping offline and online features consistent — across training, serving, and the minutes between them. The failure modes that corrupt models silently. And why the feature store is the seam where data engineering and machine learning either meet cleanly or break catastrophically.