Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 1 of 6 · Concept · 25 min · revision 2

Inside a Cloud Warehouse: Storage, Compute, Billing

See how a cloud warehouse keeps data in compressed columns on shared storage, runs queries in parallel on separate compute clusters, and turns that design into bills for storage, compute time or bytes scanned.

Contentsand lesson path

What you will learn

  • Explain how cloud warehouses separate storage from compute, use columnar storage and parallel execution, and bill for storage, compute or bytes scanned.

01. Why it matters

A cloud data warehouse, such as BigQuery, Snowflake or Amazon Redshift, is a database built for analytical queries: questions that read millions of rows and a few columns, such as revenue per country per month. It is not built for the many small reads and writes of an application. Teams that treat it like a normal database are surprised twice: by queries that are slow for no clear reason, and by the bill. Both surprises have the same cause, the way the warehouse stores data and runs queries. This lesson explains that design and how each part is billed, so you can predict cost before you run a query and read a bill when it arrives.

02. Storage and compute are separate

In a traditional database server, the disks and the CPUs are in the same machine. To get more of one you buy more of both, and every workload shares them. Most modern cloud warehouses separate storage from compute. The data lives in a storage layer, usually the cloud provider's object storage, as many compressed files. Compute is a pool of machines that reads those files when a query runs, and can be started, resized and stopped independently.

This has three practical effects. First, storage and compute scale and are billed separately: keeping 50 TB costs the same whether you query it once a month or all day. Second, several compute clusters can read the same data at the same time, so a heavy nightly load and the morning dashboards can run on different clusters and stop competing for CPU. Snowflake calls these clusters virtual warehouses; BigQuery allocates slots, units of compute, from a shared pool. Third, compute that is not running costs nothing, so clusters are often set to suspend themselves after a few idle minutes. The price of the design is that data must travel from storage to compute, which is why warehouses cache recently read files on the compute nodes and why reading less data matters so much.

03. Columns and parallel execution

Warehouses store tables by column: all values of country together, then all values of amount, and so on, in blocks of a few hundred thousand rows. A query that uses two columns of a fifty-column table reads only those two, and similar values next to each other compress very well. Each block also records the minimum and maximum of every column, so a filter such as order_date >= '2026-11-01' can skip blocks whose maximum date is earlier. Snowflake calls these blocks micro-partitions. The lesson Row vs Columnar: Inside Avro and Parquet shows the same layout in a Parquet file.

Queries run with massively parallel processing (MPP): the data is split into slices, each compute node scans its own slice and computes a partial result, and a coordinator merges the partial results. The script below simulates four nodes with DuckDB (pip install "duckdb==1.5.6"). Each node owns the rows whose hashed sale_id lands on it, as rows are spread across nodes in a real warehouse.

Python · mpp.py
"""Simulate four MPP nodes: each aggregates its own slice, a coordinator merges."""
import duckdb

con = duckdb.connect()
con.execute("""
    CREATE TABLE sales AS
    SELECT i AS sale_id, ['DE', 'FR', 'VN'][i % 3 + 1] AS country,
           CAST(i * 37 % 10000 / 100 AS DECIMAL(10, 2)) AS amount
    FROM range(1000000) AS t(i)""")

# Each node owns the rows whose hash of sale_id lands on it (its "slice").
partials = con.sql("""
    SELECT hash(sale_id) % 4 AS node, country,
           sum(amount) AS part_sum, count(*) AS part_count
    FROM sales GROUP BY ALL""")
merged = con.sql("""
    SELECT country, sum(part_sum) AS revenue, sum(part_count) AS orders,
           round(sum(part_sum) / sum(part_count), 4) AS avg_amount
    FROM partials GROUP BY country ORDER BY country""")
single = con.sql("""
    SELECT country, sum(amount) AS revenue, count(*) AS orders,
           round(avg(amount), 4) AS avg_amount
    FROM sales GROUP BY country ORDER BY country""")
print("partial rows sent to the coordinator:", partials.count("*").fetchone()[0])
print("merged result equals single-node result:",
      merged.fetchall() == single.fetchall())
print(merged)
Expected output (python mpp.py)
partial rows sent to the coordinator: 12
merged result equals single-node result: True
┌─────────┬───────────────┬────────┬────────────┐
│ country │    revenue    │ orders │ avg_amount │
│ varchar │ decimal(38,2) │ int128 │   double   │
├─────────┼───────────────┼────────┼────────────┤
│ DE      │   16665033.21 │ 333334 │     49.995 │
│ FR      │   16664966.79 │ 333333 │     49.995 │
│ VN      │   16665000.00 │ 333333 │     49.995 │
└─────────┴───────────────┴────────┴────────────┘

A million rows became 12 partial rows, 4 nodes times 3 countries, and only those 12 travel to the coordinator. Notice that the nodes send a sum and a count, not an average: the average of four averages is only correct when every node holds the same number of rows. Every aggregate that a warehouse runs in parallel has to be split this way, and some, such as an exact count of distinct values, are expensive to split, which is one reason they are slow at scale.

04. How warehouses bill

You will meet three ways of paying for compute, plus a separate charge for storage:

  • Storage: a price per terabyte per month for the compressed data, often with extra charges for history kept for time travel or recovery.
  • Per-second compute: you pay while a cluster runs, at a rate set by its size. In Snowflake, each size step doubles the credits per hour, and billing is per second with a 60-second minimum each time a warehouse starts.
  • On-demand, by bytes scanned: you pay for the data each query processes, whatever cluster ran it. BigQuery on-demand pricing counts the bytes in the columns a query reads, after partition and cluster pruning, with a minimum of 10 MB per table referenced. LIMIT does not reduce the charge, because the columns are read before the limit is applied.
  • Capacity or reservations: you pay a fixed rate for compute you reserve, used or not, often cheaper per unit when you commit for a year.

Which model is cheapest depends on the workload, not on the vendor. The calculator below uses made-up prices to compare a small team that runs reports a few times a month with dashboards that refresh all day.

Python · billing.py
"""Estimate one month of query cost under three billing models.

All prices are made up for this example. Real prices differ by vendor, region and
edition, and change over time; always read the vendor's pricing page.
"""
PRICE_PER_TIB_SCANNED = 5.00   # on-demand: pay per TiB the queries read
PRICE_PER_CREDIT = 3.00        # per-second compute: pay while a cluster runs
CREDITS_PER_HOUR = 4           # the cluster size we would need
RESERVED_PER_MONTH = 3500.00   # capacity: a flat fee for a reserved cluster

WORKLOADS = {
    # name: (queries per month, TiB read per query, cluster hours per month)
    "monthly reporting team": (300, 0.05, 20),
    "all-day BI dashboards": (90_000, 0.02, 600),
}

for name, (queries, tib_per_query, hours) in WORKLOADS.items():
    on_demand = queries * tib_per_query * PRICE_PER_TIB_SCANNED
    per_second = hours * CREDITS_PER_HOUR * PRICE_PER_CREDIT
    print(f"{name}:")
    tib = queries * tib_per_query
    print(f"  on-demand    {on_demand:>10,.2f}  ({tib:,.0f} TiB read)")
    print(f"  per-second   {per_second:>10,.2f}  ({hours} cluster hours)")
    print(f"  reserved     {RESERVED_PER_MONTH:>10,.2f}  (flat)")
Expected output (python billing.py)
monthly reporting team:
  on-demand         75.00  (15 TiB read)
  per-second       240.00  (20 cluster hours)
  reserved       3,500.00  (flat)
all-day BI dashboards:
  on-demand      9,000.00  (1,800 TiB read)
  per-second     7,200.00  (600 cluster hours)
  reserved       3,500.00  (flat)

For the reporting team, paying per query is cheapest by far, because they use little compute and a reservation would sit idle. For the dashboards, the same model is the most expensive: tens of thousands of queries a month add up, and a reserved cluster that is busy most of the time costs less. The crossover point is the question to answer for your own team. Two habits help with any model: read only the columns you need, and filter on the columns the table is partitioned or clustered by, so fewer bytes are scanned and less compute time is used. The labs later in this skill measure both.

05. Check your understanding

Practice check · 3 questions

Storage, compute and billing

Pick the best answer for each situation.

Q1. In `mpp.py`, suppose each node sent only its average amount per country, and the coordinator averaged the four averages. When would the result be wrong?
Q2. A scheduler resumes a suspended Snowflake warehouse every 15 minutes for one 10-second query, and the warehouse suspends straight after. How much running time is billed for each run?
Q3. A warehouse holds 5 TB of compressed data. In one quiet week, no query runs and every cluster stays suspended. What does that week cost?
Practice only: not graded, not saved, not evidence.

06. Apply it

Before the skill practice, write down which billing model your chosen warehouse uses (a cloud free tier, or DuckDB as a local stand-in, where you can still count bytes and time). Estimate the monthly cost of your fixed query set under at least two models with billing.py, using the vendor's current published prices instead of the made-up ones. Keep the estimate: the labs ask you to compare it with what query history actually shows.

07. Review prompt

Without looking back, explain: what separating storage from compute lets you do and what it costs; why columnar storage reads less data for analytical queries; how MPP splits an aggregate across nodes and why averages need care; and the difference between storage charges, per-second compute, on-demand bytes scanned and reserved capacity, with one workload that suits each.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

8 questions · about 6 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check