BigQuery Partitioning Strategy for Lifecycle Analysis
Short answer
D Re-create the table using data partitioning on the package delivery date to enable partition pruning for lifecycle queries.
Question
company want to query the tracking data in BigQuery to analyze geospatial trends in the lifecycle of a package. The table was originally created with ingest-date
partitioning. Over time, the query processing time has increased. You need to implement a change that would improve query performance in BigQuery. What
should you do?
Key Takeaways
Aligning partition keys with the primary query filter criteria (delivery date vs. ingest date) allows BigQuery to skip irrelevant data blocks, significantly reducing scan size.
Improve BigQuery query performance for package lifecycle analysis by switching from ingest-date to delivery-date partitioning. This enables efficient partition pruning.
Common mistake: Choosing clustering on package ID (B) is a common trap. Clustering is less effective than partitioning for broad lifecycle queries and struggles with high-cardinality unique identifiers.
Expert Analysis
The question asks for a change to improve query performance for analyzing geospatial trends in the lifecycle of a package. The current table uses ingest-date partitioning.
Option A suggests clustering on the ingest date. This is redundant because the data is already partitioned by that column, and clustering on a high-cardinality or partition-key column provides minimal benefit.
Option B suggests clustering on the package-tracking ID. While clustering helps with filtering, package IDs are typically high-cardinality (unique per event or shipment). Clustering on high-cardinality columns is generally inefficient and not recommended for significant performance gains in BigQuery compared to partitioning strategies aligned with query patterns.
Option C involves tiering data to Cloud Storage. This reduces storage costs but does not inherently improve query performance within BigQuery; external tables often have higher latency than native BigQuery tables.
Option D suggests re-partitioning by package delivery date. Analyzing a 'lifecycle' implies tracking a package from start to finish. If partitioned by ingest date, a single package's events may span many partitions (days), forcing the query engine to scan all of them. By partitioning on the delivery date (or a date associated with the specific stage of the lifecycle being analyzed), you can potentially limit scans if the analysis is scoped to specific delivery windows. However, the most critical insight from the comments and exam logic is about partition pruning. If the analyst queries for packages delivered on a specific date or within a range, partitioning by delivery date allows BigQuery to skip irrelevant partitions entirely. Ingest-date partitioning forces a full table scan for any query not strictly bound to ingestion time, which explains the increasing processing time as data grows.
Therefore, changing the partitioning key to align with the analytical workload (delivery date) is the correct architectural change to enable efficient partition pruning.
Official Reference
https://cloud.google.com/bigquery/docs/partitioned-tables
This link opens the official vendor documentation in a new tab.
Exam Strategy
When optimizing BigQuery performance, always map the query's WHERE clause filters to the table's partition and clustering keys. If a query consistently filters on a non-ingestion timestamp (like delivery date), partitioning by that field is superior to clustering, especially when the data volume is large.
Frequently Asked Questions
Why not cluster on package ID?
Does clustering replace partitioning?
Community Votes
78% of anonymous learners picked answer B. Votes are pick records left by other test-takers — they are not the verified answer.
Discussion 16 contributions
Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.
From public community threads 16
-
kcl10 👍 4 Answered DD is the correct answer requirements: analyze geospatial trends in the lifecycle of a package cuz the data of the lifecycle of the package would span across ingest-date-based partition table, it would degrade the performance. hence, re-partitoning by package delivery date, which is the package initially delivered, would improve the performance when querying such table.
-
AlizCert 👍 3 Answered BThough I almost fell for D, but the delivery date information is only available on the event(s) that happen after the delivery, but not on the ones before where it will be NULL I guess. The only other option that can make some sense is B, though high cardinality is not recommended for clustering.
-
sdi_studiers 👍 3 Answered DI vote D Queries to analyze the package lifecycle will cross partitions when using ingest date. Changing this to delivery date will allow a query to full a package's full lifecycle in a single partition.
-
Aman47 👍 3 Answered BPackage Tracking mostly contains, geospatial prefixes, Like HK0011, US0022, etc, this can help in clustering.
-
John_Pongthorn 👍 3D is not correct becsuse This Is problem Is The Real Time so ingested date is the same as delivery date.
Show 11 more comments
-
MaxNRG 👍 2 Answered BB as Clustering the data on the package Id can greatly improve the performance. Refer GCP documentation - BigQuery Clustered Table:https://cloud.google.com/bigquery/docs/clustered-tables
-
pluiedust 👍 2 Answered BB; As the table has already created with ingest-date partitioning.
-
jkhong 👍 2The table has already been partitioned
-
MaxNRG 👍 1Clustering can improve the performance of certain types of queries such as queries that use filter clauses and queries that aggregate data. When data is written to a clustered table by a query job or a load job, BigQuery sorts the data using the values in the clustering columns. These values are used to organize the data into multiple blocks in BigQuery storage. When you submit a query containing a clause that filters data based on the clustering columns, BigQuery uses the sorted blocks to eliminate scans of unnecessary data. Currently, BigQuery allows clustering over a partitioned table. Use clustering over a partitioned table when: - Your data is already partitioned on a date, timestamp, or integer column. - You commonly use filters or aggregation against particular columns in your queries. Table clustering is possible for tables partitioned by: - ingestion time - date/timestamp - integer range
-
MaxNRG 👍 1Although more metadata must be maintained, by ensuring that data is partitioned globally, BigQuery can more accurately estimate the bytes processed by a query before you run it. This cost calculation provides an upper bound on the final cost of the query. In a clustered table, BigQuery automatically sorts the data based on the values in the clustering columns and organizes them in optimally sized storage blocks. You can achieve more finely grained sorting by creating a table that is clustered and partitioned. A clustered table maintains the sort properties in the context of each operation that modifies it. As a result, BigQuery may not be able to accurately estimate the bytes processed by the query or the query costs. When blocks of data are eliminated during query execution, BigQuery provides a best effort reduction of the query costs.
-
carbonscave 👍 1 Answered BWhy B is correct Aligning Storage with Query Patterns: To analyze the "lifecycle of a package," analysts must group or filter the real-time events by the specific package's identifier. Block Pruning via Clustering: While partitioning divides the table into large, day-sized chunks, clustering sorts the data inside those chunks based on a specific column. By clustering on the package-tracking ID, BigQuery organizes all events for a single package closely together on disk. When an analyst queries a specific package's lifecycle, BigQuery can instantly skip over irrelevant data blocks (block pruning), drastically reducing the bytes scanned and accelerating query execution time.
-
MaxNRG 👍 1In a table partitioned by a date or timestamp column, each partition contains a single day of data. When the data is stored, BigQuery ensures that all the data in a block belongs to a single partition. A partitioned table maintains these properties across all operations that modify it: query jobs, Data Manipulation Language (DML) statements, Data Definition Language (DDL) statements, load jobs, and copy jobs. This requires BigQuery to maintain more metadata than a non-partitioned table. As the number of partitions increases, the amount of metadata overhead increases.
-
John_Pongthorn 👍 1There are several rows that represent movement of life cycle of 1 package-tracking ID package delivery date = ingestion date , i suppose
-
AWSandeep 👍 1 Answered BB. Implement clustering in BigQuery on the package-tracking ID column.
-
cloudmon 👍 1 Answered BB. https://cloud.google.com/bigquery/docs/clustered-tables
-
kenanars 👍 1why not D ?
Reader comments & corrections
No reader corrections yet — spotted an error or have a note? Share it below.