TECHNOLOGIESTieInn Technologies

BigQuery partitioning, clustering, and cost

GCP · 13 questions

Short notes

Key idea

BigQuery bills on-demand queries by bytes read. Partitioning lets a query skip whole days; clustering sorts data so it skips blocks within them. Together they cut cost and time.

Syntax

CREATE TABLE sales.orders
PARTITION BY DATE(order_ts)
CLUSTER BY customer_id, city
OPTIONS (require_partition_filter = TRUE)
AS SELECT * FROM staging.orders;
  • Partition by a date/timestamp column, ingestion time, or an integer range.
  • Cluster by up to 4 columns used in filters or joins.
  • Check "bytes processed" in the query validator before running.
  • Custom quotas cap bytes per user or project per day.

Example

Unpartitioned 1 TB table, a query for one week: ~1 TB billed. Partitioned by day: ~20 GB. With require_partition_filter, a query with no date filter is refused instead of scanning everything.

Traps

  • Wrapping the partition column in a complex expression can stop pruning.
  • Clustering's savings don't show in the estimate; they appear in the final bytes billed.
  • Too many small partitions (hourly over years) hit limits; daily is the usual choice.
  • Preview a table in the UI instead of SELECT * to look at it for free.

Want the full lesson with step-by-step examples, a project and a certificate? GCP course, ₹120 →

Questions

5 free questions
5 questions

    BigQuery partitioning, clustering, and cost

  1. Question 1easy

    Where can you see how many bytes a query will process before you run it?

  2. BigQuery partitioning, clustering, and cost

  3. Question 2medium

    What happens when a query would scan more than its "maximum bytes billed" setting?

  4. BigQuery partitioning, clustering, and cost

  5. Question 3medium

    A table is partitioned by order_date. Which filter prunes partitions?

  6. BigQuery partitioning, clustering, and cost

  7. Question 4medium

    A dashboard refreshes every 15 minutes and scans a 2 TB fact table each time. What's the best fix?

  8. BigQuery partitioning, clustering, and cost

  9. Question 5medium

    A table needs 40 years of history. Why might daily partitioning be a problem?

8 more questions on this topic, with hints, and tests

Sign up free for 21 days of every question and test.