You are investigating a slow dashboard query that aggregates data from the BigQuery table sales.transactions, partitioned on the DATE column transaction_date. The EXPLAIN plan shows the first stage scanning 4.5 TB with the note partition pruning: NONE. The SQL contains the filter WHERE DATE(transaction_ts) >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY). Which change will most reduce data scanned and alleviate the bottleneck without purchasing additional slots?
Purchase a dedicated 2,000-slot BigQuery reservation so the query has more parallel resources.
Rewrite the predicate to WHERE transaction_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 7 DAY) so the filter references the partition column directly, enabling partition pruning.
Add clustering on customer_id to the sales.transactions table to improve selective reads.
Insert the /*+ BROADCAST_JOIN(orders) */ hint to avoid repartitioning during joins in the query plan.
BigQuery can eliminate whole partitions from a scan only when the predicate directly references the partitioning column with a simple comparison. Wrapping the timestamp in the DATE() function prevents the optimizer from applying partition pruning, so every partition is still read. Rewriting the filter to compare the native partition column (transaction_date) or to use _PARTITIONDATE enables the optimizer to read only the last seven partitions, cutting the scanned bytes dramatically. Adding more slots, clustering on a different key, or changing join hints does not remove the fundamental waste of scanning unnecessary partitions, so they will not deliver comparable performance gains.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What is partition pruning in BigQuery?
Open an interactive chat with Bash
How does using `_PARTITIONDATE` improve query performance?
Open an interactive chat with Bash
What is the difference between clustering and partitioning in BigQuery?
Open an interactive chat with Bash
What is partition pruning in BigQuery?
Open an interactive chat with Bash
What is the difference between a partition column and the `_PARTITIONDATE` pseudo column in BigQuery?
Open an interactive chat with Bash
How does wrapping a column in a function (like `DATE()`) affect query optimization in BigQuery?
Open an interactive chat with Bash
GCP Professional Data Engineer
Preparing and using data for analysis
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .