← Complete program

Chapter 14 · Course 4 c14-m04

How can we use a warehouse without waste?

Your goal Reduce and estimate the data scanned by a warehouse query using a partition filter, a dry run, and a limit.

The lesson, the vocabulary, the worked example and the mission are separate blocks. You can follow them in order or return to the one you need.

Video explanation

This English explanation has English subtitles. Its examples may use a separate practice dataset; use the data stated in the written mission for your answers.

01

Story · optional context

The story so far

You are the new data recruit at Aster Motors. Luca was hurt in a crash, the Noctis 01 vanished, and Voss is trying to blame you. Mara Sol and investigator Imani have preserved the original files supplied by partners. A clue shows that a service account had too much access, but the team does not know whether it changed data. To compare vehicle passages on the two nights surrounding the crash, Mara wants to query a practice copy without scanning the whole month each time.

This lesson stands on its own. Object storage holds files; a data warehouse arranges tables so we can ask questions using SQL. BigQuery is one cloud warehouse. Query cost may depend on bytes read and the pricing model. You will select two date partitions, estimate the bytes scanned, read a SQL query, and set an imaginary limit before any run. No real cloud project is opened.

02

Before the lesson

Purpose of this course

Reduce and estimate the data scanned by a warehouse query using a partition filter, a dry run, and a limit.

Topics covered

Distinguish files in Cloud Storage from rows in a BigQuery table.; Explain a date partition and why filtering it can reduce scanned data.; Compare bytes scanned for two days and for one month in a numerical example.; Explain a dry run and a maximum bytes billed setting, and why LIMIT alone is insufficient.

What you will learn

  • Distinguish files in Cloud Storage from rows in a BigQuery table.
  • Explain a date partition and why filtering it can reduce scanned data.
  • Compare bytes scanned for two days and for one month in a numerical example.
  • Explain a dry run and a maximum bytes billed setting, and why LIMIT alone is insufficient.

PART 1 · THE LESSON

Understand step by step

1

Lesson · explanation

Keeping source files and querying a table are different actions

Imani keeps the original Noctis 01 investigation files with their names and origins. Mara separately prepares a working table to count observations from two nights around Luca's crash. Object storage, such as Cloud Storage, is designed to keep complete files. A data warehouse, such as BigQuery, is designed to ask questions of organized tables with SQL. Placing a file in storage does not automatically create a trustworthy table. Its format, dates, duplicates, and transformation rules must first be examined.

Picture an archive cabinet and a classroom chart. The cabinet holds the pages as received, while the chart copies selected facts so a question can be answered quickly. If the chart shows two passages but the original page has three lines, one perhaps a correction, you must be able to return to that page and explain the difference. Here, the preserved files remain the reference for checking the derived table. The table makes analysis easier but does not replace its sources.

The fictional table noctis_lab.telemetry_events has an event_date column. The exercise assumes it was prepared from a copy and organized by day. Mara needs only April 12 and 13, 2026. Voss wants a number from the whole month immediately, but scanning unrelated days cannot by itself strengthen the evidence about those two nights. A wider query can read substantially more data and make repeated attempts more expensive under a relevant pricing model.

This lesson begins from zero: a query is a question written in SQL; a row represents one table observation; a partition is one compartment of the table. The volumes below are invented so that you can practice calculations. No cloud account is needed. You can draw thirty boxes on paper, mark the two useful boxes, and explain your choice to Mara using both the numbers and the units.

Pause and think

Why preserve received files when the count is made from a table?

See the explanation

Files preserve identifiable sources; the derived table is a working copy whose rows and counts must be checked against them.

2

Lesson · explanation

A date partition is like a drawer for each day

A date-partitioned table divides its data into compartments based on a date column. In this exercise, each value of event_date labels one daily drawer. If the question concerns April 12 and 13, the query filters those dates. BigQuery can skip the other partitions when the table is truly partitioned on the relevant column and the filter can be used for partition pruning. Pruning means avoiding compartments the query does not need; it is conditional, not a magical property of every WHERE clause.

Imagine a library with one drawer per day. To examine two nights, open drawers 12 and 13 instead of all thirty drawers of the month. This saving depends on the cards having been filed under those day labels and on your request using the right label. If the table is not partitioned by event_date, writing WHERE event_date ... may still filter returned rows but does not guarantee the same reduction in data scanned. First inspect the table definition.

The example condition is WHERE event_date BETWEEN DATE '2026-04-12' AND DATE '2026-04-13'. In SQL, BETWEEN includes both endpoints here, so the selected range covers precisely the twelfth and thirteenth. Before a real run, verify the event_date type, the table's partition column, the time zone used to derive the date, and whether this particular filter allows pruning. An event close to midnight can fall in a different daily drawer if local time and UTC are confused.

For the mission, state both the column and the dates you would filter. Saying only 'I will add WHERE' is too vague: the condition must target the assumed partition column and the intended range. The expected reduction must be checked through an estimate, rather than inferred from the word WHERE alone. Even if the partition filter works, the returned rows are still table observations that need comparison with Imani's preserved source files.

Pause and think

Which column and dates should this simulated query filter?

See the explanation

The event_date partition column, April 12 through April 13, 2026, inclusive.

3

Lesson · explanation

Compare two days with the full month using units

The practice sheet assumes thirty daily partitions of 2 GB each. Under this deliberately simple model, reading the full month means about 30 × 2 = 60 GB. Reading only two useful partitions means 2 × 2 = 4 GB, if the other partitions can actually be pruned. The ratio is 60 ÷ 4 = 15. Thus the full-month scan is fifteen times the two-day scan in this fictional comparison. These values are not measurements of a real BigQuery table.

Think of thirty identical boxes weighing 2 kilograms each. Carrying every box totals 60 kilograms; carrying just two totals 4 kilograms. Their weight describes effort, not whether the contents are true. Likewise, gigabytes scanned describe an amount of reading and may affect cost depending on the pricing model. They are not a count of vehicle movements and do not identify who was driving Noctis 01. Keep data volume and evidence value as separate questions.

Suppose Mara tries the query five times each day for thirty days. That is 5 × 30 = 150 query attempts. At the model's two-day estimate, repeated scanning would total 150 × 4 = 600 GB. At the full-month estimate, it would total 150 × 60 = 9,000 GB. The per-query difference of 56 GB becomes much larger through repetition. Write the multiplications and units explicitly so that query counts are not confused with gigabytes.

Real processed or billed bytes may vary with selected columns, table layout, service behavior, and the chosen pricing model. The arithmetic is a learning comparison, not a certified bill. In your answer give all four numbers, 4, 60, 600, and 9,000 GB, with the situation attached to each. 'Fifteen times cheaper' would overstate the lesson: we calculated a ratio of imaginary scanned volumes, not a guaranteed price.

Pause and think

What are the two-day and thirty-day volumes, and the totals across 150 attempts?

See the explanation

Two days: 4 GB; thirty days: 60 GB. Across 150 attempts: 600 GB versus 9,000 GB in the fictional model.

4

Lesson · explanation

A dry run estimates a query before execution

A query dry run checks the query and estimates the volume it would process without executing it to produce results. It resembles asking a moving company how many boxes will need carrying before loading the truck. In BigQuery, this estimate can show whether the date filter is likely to reduce scanned data. It can expose a forgotten partition condition or a wider column selection. A short-looking SQL statement is not automatically a small query; inspect its estimated bytes.

In the exercise, we expect roughly 4 GB for two daily partitions and 60 GB for all thirty. A real dry run need not return these invented figures. It uses the actual table and actual query. If its estimate looks close to the full month, pause and inspect whether event_date really is the partition column, whether the condition is usable for pruning, and whether the query selects more fields than needed. Revise the query and estimate again.

The dry run does not prove that the result rows are correct. It does not compare their contents with source files or reveal who changed a record. It mainly answers whether the query is valid enough to analyze and how much data the service estimates it will process. The investigation still needs a separate quality check: dates, IDs, and source_file provenance in the warehouse should be reconciled with the files Imani retained.

A careful sequence for Mara is to write the narrow two-date SQL, request a dry run, read the byte estimate, and compare it with the agreed spending boundary. If the estimate is too large, adjust the partition filter or selected columns and request another estimate. This preparation is safer than repeatedly running a broad query until the visible result happens to be short. No live cloud operation is necessary for this paper exercise.

Pause and think

What should you inspect if a two-day dry run estimates almost the whole month?

See the explanation

Check the actual partition column, event_date filter, selected columns, and whether the query permits partition pruning.

5

Lesson · explanation

A maximum-byte setting and LIMIT 10 solve different problems

A maximum bytes billed setting places a ceiling on the billable bytes of a query under an applicable service configuration. The service can reject a query whose estimated volume exceeds that ceiling. In our simplified model, a 5 GB maximum could theoretically allow an estimated 4 GB query and reject an estimated 60 GB query. Before any authorized real use, confirm the actual service behavior, units, and pricing model. This setting is a query guard, not a complete budget policy.

LIMIT 10 means 'return no more than ten result rows.' It does not mean 'read only ten input rows.' Imagine searching for ten cards bearing a name in an unindexed cabinet: you may need to examine many drawers before finding the ten cards, and a database engine may scan much more than the visible output. LIMIT 10 on a broad query therefore does not promise fewer partitions or fewer billable bytes. Output size and input scanning are different measures.

Suppose Voss adds LIMIT 10 to a query over the entire month and calls it cheap. You can challenge that claim with a precise reason: ten rows displayed reveal nothing reliable about the partitions scanned. Instead, select the two needed dates, choose relevant columns, request a dry run, and set a maximum compatible with the approved budget. The project budget and access permissions are separate safeguards; the bytes setting alone cannot decide who may run the query.

Even an estimate of 4 GB under a 5 GB maximum does not authorize someone to use a real cloud account. Here all work stays hypothetical. For the mission, distinguish the controls by job: a partition filter can narrow candidate data, a dry run estimates the planned scan, and a maximum may prevent a query above its ceiling. LIMIT 10 mainly restricts rows returned. It cannot replace the other three checks.

Pause and think

Why does LIMIT 10 not replace a partition filter or maximum bytes billed?

See the explanation

It limits returned rows but does not guarantee fewer scanned partitions or bytes.

6

Lesson · explanation

Read a count without mistaking it for proof

The example SQL uses SELECT event_date, COUNT(*) to choose a date and count rows; FROM names the fictional table. WHERE selects April 12 and 13; GROUP BY creates one count for each date; ORDER BY sorts the dates. If the derived table holds two observations for the twelfth and one for the thirteenth, the result is 12 → 2 and 13 → 1. Those numbers describe rows present in this version of the prepared table under this query.

Imagine counting three footprints on a sheet. Three is the correct count of visible marks, but it does not tell you whether three different people left them or whether one was copied. Similarly, COUNT(*) does not establish that every row has an authentic source or that Noctis 01 physically traveled at the stated time. Imani must compare the rows with original files, access logs, and known corrections before using the count in an accusation or report.

Keep the written SQL, the two-date range and its time zone, the dry-run estimate, the chosen ceiling, and the table version. Another investigator can then repeat the count and investigate a difference. A later table correction might change the total without any new physical vehicle movement. Version and provenance records help explain that variation before anyone assigns blame. Reproducibility is useful only when the source relationship is also understood.

Answer Mara in order: original files remain preserved, and SQL queries a derived table. Filter event_date for April 12 and 13. Calculate 4 versus 60 GB, then 600 versus 9,000 GB across repeated attempts. Explain the dry run, possible 5 GB ceiling, and why LIMIT 10 is not a scanning cap. Finish by saying that the per-day count must still be checked against source evidence. This advances the investigation without turning arithmetic into a verdict.

Pause and think

What does a result of 12 → 2 and 13 → 1 mean?

See the explanation

The derived table has two counted rows dated the twelfth and one dated the thirteenth; their authenticity still needs checking.

Visual guide

Choose the right compartments

  1. 1Original files: object storage
  2. 2Table copy: 30 partitions × 2 GB = 60 GB
  3. 3Two-date filter: 2 partitions × 2 GB = 4 GB
  4. 4Dry run: estimate before execution

Filtering the actual partition column reduces work; LIMIT alone is no substitute.

SQL · query or table structure

Count two days in an imaginary BigQuery table

SELECT event_date, COUNT(*) AS observations
FROM `noctis_lab.telemetry_events`
WHERE event_date BETWEEN DATE '2026-04-12' AND DATE '2026-04-13'
GROUP BY event_date
ORDER BY event_date;

This is BigQuery Standard SQL, but the table name is fictional. WHERE filters event_date, our assumed partition column. GROUP BY counts observations for each date. Read the query; this lesson does not ask you to run it on a real account.

PART 2 · WATCH IT WORK

A complete worked example

Follow each step, then the result

Worked example: two nights instead of a month

Each day is an imaginary 2 GB; the table covers 30 days. Mara needs April 12 and 13 only.

  1. Calculate a full month: 30 × 2 GB = 60 GB.
  2. Calculate the two useful partitions: 2 × 2 GB = 4 GB.
  3. Compare: 60 ÷ 4 = 15. Across 150 tries, this model gives 9,000 GB versus 600 GB.
  4. Before any real execution, request a dry run and set a limit suitable for the estimate and approved budget.
What this shows

A good filter can sharply reduce scanned data; checking the estimate before execution avoids surprises.

How this helps with your mission

The worked comparison uses two useful daily partitions versus thirty: 4 GB against 60 GB, then 600 GB against 9,000 GB for 150 attempts. In the mission, connect those fictional calculations to an event_date filter for April 12 and 13, 2026. Explain why the original files remain preserved while SQL queries a table copy. Propose a dry run and a hypothetical 5 GB maximum before an authorized query. Reject LIMIT 10 as a guarantee of low scanning. The daily total helps Mara focus the missing night but establishes neither the rows' truth nor a culprit.

PART 3 · YOUR TURN

Use the lesson to solve the mission

Story scene · practical task

Mission: find the missing night without draining the budget

Mara gets a message from Voss: 'Query the whole table and publish the number now.' Imani first wants the two nights around the crash and the preserved source files. Propose a narrow query, explain its imaginary data volume, and refuse to treat a row count as final proof. The meeting is urgent in the story; the exercise has no timer.

Your task

  1. Explain why originals are kept as files while counts use a table copy.
  2. Name the column and two-date range the query filters.
  3. Calculate volumes for two days and 30 days, then compare them.
  4. Explain a dry run, a 5 GB limit, and why LIMIT 10 cannot replace the filter.

How to know you have succeeded

  • Object storage for files; warehouse for table analysis.
  • event_date from April 12 through 13, 2026.
  • 4 GB versus 60 GB; the month scans 15 times as much in this model.
  • Dry run estimates; a limit can reject a broad query; LIMIT alone does not prune partitions.
Open this mission in the browser workspace

Try code or SQL and keep a local draft. The mission questions are checked separately below.

Check the facts in your mission

Answer each factual question, then write your report in your own words. The program checks the choices; compare the report with the worked answer below.

1. Why preserve original files when counting uses a table?
2. Which filter targets the exercise's two partitions?
3. With thirty 2 GB days, how much is read for two days and the whole month in this model?
4. For 150 attempts, what modeled volumes correspond to two days and the full month?
5. What roles do dry run, a 5 GB maximum, and `LIMIT 10` play?
See the worked answer
  1. Files preserve identifiable sources. A derived table makes totals easy but must be checked against those files before any conclusion.
  2. WHERE event_date BETWEEN DATE '2026-04-12' AND DATE '2026-04-13' selects the two assumed partitions.
  3. 2 × 2 = 4 GB; 30 × 2 = 60 GB; 60 ÷ 4 = 15. Across 150 tries, that is 600 GB versus 9,000 GB in the fictional model.
  4. A dry run checks the estimate before execution. A 5 GB maximum can allow 4 GB and reject 60 GB under the service's rules. LIMIT 10 restricts returned rows, not necessarily bytes scanned. Results still need source verification.

You can now connect access rights, infrastructure, and analysis cost. Next you will turn these controls into a monitored data pipeline where each step leaves a verifiable trace.

Before you leave

Remember this

  • Object storage preserves complete files; a warehouse answers SQL questions using a derived table.
  • A table partitioned by event_date can skip other days if the filter is suitable and pruning works.
  • In the fictional model, two days mean 4 GB versus 60 GB for thirty days, a factor of fifteen.
  • Across 150 attempts, simplified totals are 600 GB with the two-day scan versus 9,000 GB for the whole month.
  • A dry run estimates before execution; a maximum bytes billed setting can reject a broad query under applicable conditions.
  • LIMIT 10 restricts returned rows, not necessarily bytes scanned; COUNT(*) does not authenticate the rows.
A–Z

Part of the lesson · keep nearby

New words, explained

These are the names of ideas used in the lesson above. Return here whenever a word feels unfamiliar.

Object storage
A service that keeps complete named files as objects.
Data warehouse
A service designed to analyze tables with queries.
BigQuery
A Google Cloud data warehouse used as an example here.
Partition
A section of a table, such as one day's rows.
Partition pruning
Skipping partitions outside a filter when the table and query allow it.
Bytes scanned
Amount of data read during a query.
Dry run
Checking and estimating a query without executing it.
Maximum bytes billed
A limit that can reject a query whose billable data volume is too large.

Official references