bq-query-optimization

Optimize and debug BigQuery SQL queries for performance and cost.

1|Updated Dec 11, 2025
One-click install
npx skills add https://github.com/FunnelEnvy/agents_webinar_demos --skill bq-query-optimization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bq-query-optimization
Source: https://github.com/FunnelEnvy/agents_webinar_demos/tree/main/.claude/skills/bq-query-optimization
Command: npx skills add https://github.com/FunnelEnvy/agents_webinar_demos --skill bq-query-optimization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps analysts optimize and debug BigQuery SQL queries for performance and cost.

Core Features & Use Cases

  • Parameterized queries: write safe, reusable SQL with bound parameters to improve caching and readability.
  • Advanced functions: leverage UDFs, scripting, and window functions (QUALIFY, ROW_NUMBER, RANK, LEAD/LAG) to simplify complex analyses.
  • BigQuery-specific patterns: apply best practices for EXCEPT/REPLACE usage, JSON/ARRAY/STRUCT handling, NOT IN with NULLs, and efficient DML.
  • Use Case: optimize a nightly analytics query that scans a large dataset, replacing SELECT * with targeted columns and adding partition filters to reduce cost and improve performance.

Quick Start

Start with a simple query, enable parameterization, review the execution plan, and iteratively apply the optimization techniques described above. Then validate results against a non-optimized baseline.

Frequently Asked Questions about bq-query-optimization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize BigQuery SQL queries to reduce scan costs?

Avoid CTE re-execution by materializing intermediate results, apply partition filters to limit scanned data, and use targeted columns instead of SELECT * to reduce BigQuery query costs.

What's the best way to write parameterized queries in BigQuery for better caching?

Write parameterized queries in BigQuery using bound parameters to improve query caching, enhance SQL readability, and ensure safe, reusable execution plans across repeated runs.

How do I use window functions like QUALIFY and ROW_NUMBER in Standard SQL?

Use window functions like QUALIFY, ROW_NUMBER, RANK, and LEAD/LAG in Standard SQL to simplify complex analytical queries and filter rows based on windowed aggregations.

Does this approach support optimizing BigQuery DML statements and UDFs?

Yes, this approach supports optimizing BigQuery DML performance and UDFs, applying best practices for efficient data manipulation and compatibility between Standard and Legacy SQL.

Why does my BigQuery query scan so much data when using SELECT *?

Using SELECT * in BigQuery scans all columns in the table, bypassing partition pruning and clustering benefits, which significantly increases query costs and execution time.