BigQuery SQL Cheats Cheat Sheet

Partitioning, clustering, and cost control

Last Updated: November 21, 2025

Focus Areas

Focus
Filter partitions or use date-based tables to reduce bytes scanned
Cluster on selective columns for better query performance

Commands & Queries

SELECT * FROM dataset.table WHERE _PARTITIONTIME = DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
Partition filter
CREATE TABLE dataset.table PARTITION BY DATE(event_date)
Create partitioned table
SELECT APPROX_TOP_COUNT(user_id, 10) FROM dataset.table
Approximate aggregates

Summary

Guard budgets with partition filters, clustering, and approximate functions.

💡 Pro Tip: Filter by `_PARTITIONTIME` and cluster on selective columns.
← Back to Data Science & ML | Browse all categories | View all cheat sheets