Featured resource
2026 Tech Forecast
2026 Tech Forecast

1,500+ tech insiders, business leaders, and Pluralsight Authors share their predictions on what’s shifting fastest and how to stay ahead.

Download the forecast
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
    • Data
Labs

BigQuery Query Cost and Performance Optimization

A query that returns the right answer can still scan far more data than it needs to. In this lab, you'll take a working BigQuery report query and start where most analysts stop: after it runs. You'll record its bytes processed, bytes billed, and slot time, then use the execution graph to work out where that work goes. Once you've found the cause, you'll rewrite the query to skip the unnecessary work, run it again, and verify within BigQuery that the report hasn't changed and the query now costs a fraction of what it did.

Lab platform
Lab Info
Level
Intermediate
Last updated
Nov 06, 2026
Duration
30m

Contact sales

By clicking submit, you agree to our Privacy Policy and Terms of Use, and consent to receive marketing emails from Pluralsight.
Table of Contents
  1. Challenge

    Run the baseline query and record its processing evidence

    Establish what the existing finance report query costs before you change anything.

    • Review the business requirement and the baseline query.
    • Note the validator's bytes estimate before running.
    • Run the baseline query with cached results turned off.
    • Record bytes processed, bytes billed, and slot milliseconds.
    • Save the query result as the baseline_result table.
  2. Challenge

    Inspect the query plan and identify the main inefficiency

    Use BigQuery's execution evidence to find out where the baseline query's work goes.

    • Find the most expensive stages in the execution graph.
    • Relate the input and aggregation stages back to the SQL.
    • Check the table's clustering configuration and key uniqueness.
    • Identify why the query reads every column and every block of the table.
  3. Challenge

    Change the query to remove that inefficiency

    Rewrite the query so it reads only what the report needs.

    • Replace the whole-row dedupe with only the required columns.
    • Rewrite the month filter as a direct range on the clustered column.
    • Compare the validator's new estimate with the baseline estimate.
  4. Challenge

    Run the optimized query against the same requirement

    Measure what the optimized query actually costs.

    • Run the optimized query with cached results turned off.
    • Record bytes processed, bytes billed, and slot milliseconds.
    • Compare the actual bytes processed with the validator's estimate.
    • Save the query result as the optimized_result table.
  5. Challenge

    Verify the result matches and the processing cost is lower

    Prove that the optimized query returns the same report for less.

    • Compare the two result tables in both directions.
    • Retrieve both jobs' processing statistics from job history metadata.
    • Save the side-by-side evidence as the run_evidence table.
About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight