How would you optimize a slow dashboard query running on billions of rows in BigQuery?

Quick Overview

Asks how to speed up a slow BigQuery dashboard query over billions of rows. Tests reading the query plan, cutting bytes scanned with partitioning and clustering, precomputing with materialized views and caching, and fixing joins, shuffles and skew.

How would you optimize a slow dashboard query running on billions of rows in BigQuery?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

How would you optimize a slow dashboard query running on billions of rows in BigQuery? ```hint Measure first Find out which stage of the query plan dominates: bytes read, slot time, or rows shuffled between stages. Each points to a different fix. ``` ```hint Repeated work A dashboard runs the same shape of query over and over for many viewers. Think about what could be computed once and read many times. ``` ### Clarifying Questions to Ask - How fresh do the numbers need to be: near real time, hourly or daily? - Which filters do dashboard users apply most often (date range, region, customer)? - Is the main concern latency, bytes billed under on-demand pricing, or slot usage under a reservation? - How many viewers and tiles run the query, and how often does it refresh? - Is the table already partitioned or clustered, and can its schema be changed? ### What a Strong Answer Covers - Diagnosing with the query plan and job metadata before changing anything - Reducing bytes scanned through partitioning, clustering and column selection, and what defeats pruning - Precomputing repeated aggregations and caching for interactive use - Query-level fixes for joins, shuffles, skew and exact distinct counts - The freshness, cost and maintenance trade-offs of each change ### Follow-up Questions - The table is partitioned by date, yet the query still scans every partition. What would you check? - Users need numbers that are at most a few minutes old. Does a materialized view still help? - How do you choose clustering columns and their order? - When is `APPROX_COUNT_DISTINCT` unacceptable for a dashboard metric?

Overview: Asks how to speed up a slow BigQuery dashboard query over billions of rows. Tests reading the query plan, cutting bytes scanned with partitioning and clustering, precomputing with materialized views and caching, and fixing joins, shuffles and skew.

PracHub logo
General
Nov 24, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

How would you optimize a slow dashboard query running on billions of rows in BigQuery?

Clarifying Questions to Ask Guidance

  • How fresh do the numbers need to be: near real time, hourly or daily?
  • Which filters do dashboard users apply most often (date range, region, customer)?
  • Is the main concern latency, bytes billed under on-demand pricing, or slot usage under a reservation?
  • How many viewers and tiles run the query, and how often does it refresh?
  • Is the table already partitioned or clustered, and can its schema be changed?

What a Strong Answer Covers Guidance

  • Diagnosing with the query plan and job metadata before changing anything
  • Reducing bytes scanned through partitioning, clustering and column selection, and what defeats pruning
  • Precomputing repeated aggregations and caching for interactive use
  • Query-level fixes for joins, shuffles, skew and exact distinct counts
  • The freshness, cost and maintenance trade-offs of each change

Follow-up Questions Guidance

  • The table is partitioned by date, yet the query still scans every partition. What would you check?
  • Users need numbers that are at most a few minutes old. Does a materialized view still help?
  • How do you choose clustering columns and their order?
  • When is APPROX_COUNT_DISTINCT unacceptable for a dashboard metric?