BigQuery for Beginners: Datasets, Tables, SQL, Partitioning, Clustering, Pricing and Access Control
What Is BigQuery?
- Google's serverless, petabyte-scale data warehouse. You write SQL and Google runs it on thousands of machines
- Storage and compute are separate, so each scales and is billed on its own
- Storage is columnar, so queries read only the columns they need
- Also supports streaming, machine learning (BigQuery ML), geospatial, BI and querying data in Cloud Storage
| Term | Meaning |
|---|---|
| Project | Holds billing and datasets |
| Dataset | A folder of tables and views. It has a location (region or multi-region) |
| Table | Rows and columns (native, external, or a view) |
| Job | A load, query, copy or export action |
Your First Queries
sql
-- Public dataset: no loading needed
SELECT name, SUM(number) AS total
FROM `bigquery-public-data.usa_names.usa_1910_2013`
WHERE state = 'CA'
GROUP BY name
ORDER BY total DESC
LIMIT 10;
bash
bq mk --dataset --location=asia-south1 my-proj:sales
bq load --autodetect --source_format=CSV --skip_leading_rows=1 sales.orders gs://acme-reports-482/orders.csv
bq query --use_legacy_sql=false 'SELECT country, SUM(amount) revenue FROM sales.orders GROUP BY country ORDER BY revenue DESC'
bq show --format=prettyjson sales.orders
Loading Data
| Method | Use |
|---|---|
| Batch load (free) | Files from Cloud Storage: CSV, JSON, Avro, Parquet, ORC |
| Streaming / Storage Write API | Real-time rows |
| Datastream / Dataflow / Pub/Sub subscription | Pipelines and change data capture |
| Data Transfer Service | Scheduled imports from SaaS and other clouds |
| External and BigLake tables | Query files in place without loading |
Partitioning and Clustering
- Partitioned table: split by date/time column, ingestion time or integer range. Queries that filter on the partition scan only needed partitions
- Clustered table: sort data by up to four columns so filters on them scan less
- Use both: partition by date, cluster by
customer_id - Set
require_partition_filterto stop accidental full scans
sql
CREATE TABLE sales.orders_p
PARTITION BY DATE(order_ts)
CLUSTER BY customer_id, country
OPTIONS (require_partition_filter = TRUE, partition_expiration_days = 730) AS
SELECT * FROM sales.orders;
SELECT customer_id, SUM(amount) FROM sales.orders_p
WHERE DATE(order_ts) BETWEEN '2026-11-01' AND '2026-11-17' AND country = 'IN'
GROUP BY customer_id;
Pricing in Simple Terms
| Part | Model |
|---|---|
| Storage | Per GB per month. Data not changed for 90 days becomes cheaper (long-term). Logical or physical billing |
| Analysis (on-demand) | Per TB of data scanned by queries (a monthly free amount applies) |
| Analysis (capacity / editions) | Pay for slots (compute units), with autoscaling, for predictable cost on heavy use |
| Streaming and some APIs | Per volume |
| Loading and exporting | Batch load free (using shared slots) |
Controlling Cost
- Select only needed columns. Never
SELECT *on big tables - Filter on partition columns
- Use dry run to see bytes before running:
bq query --dry_run - Set maximum bytes billed per query and custom quotas per project or user
- Use
LIMITcarefully: it does not reduce bytes scanned - Use materialized views and BI Engine for repeated dashboards
- Set table expiration for temporary data
bash
bq query --use_legacy_sql=false --dry_run 'SELECT * FROM sales.orders_p WHERE DATE(order_ts) = "2026-11-17"'
bq query --use_legacy_sql=false --maximum_bytes_billed=10000000000 'SELECT country, COUNT(*) FROM sales.orders_p WHERE DATE(order_ts)="2026-11-17" GROUP BY 1'
Access Control
| Level | How |
|---|---|
| Project / dataset | IAM roles such as bigquery.dataViewer, bigquery.dataEditor, bigquery.jobUser (to run queries) |
| Authorized views | Share a view of selected columns or rows without giving access to the base table |
| Column-level security | Policy tags from Data Catalog restrict sensitive columns |
| Row-level security | Row access policies show different rows to different users |
| Data masking | Show masked values for some users |
| CMEK, VPC Service Controls, audit logs | Encryption, perimeter and tracking |
Useful Features
- Time travel: query data as it was up to 7 days ago
- BigQuery ML: train models with SQL (
CREATE MODEL) - Scheduled queries, materialized views, user-defined functions
- Looker and Looker Studio for dashboards
- BigQuery Omni to query data in AWS or Azure
Practice
- Run the public dataset query and check bytes processed
- Load a CSV from Cloud Storage with autodetect
- Create a partitioned and clustered copy and compare bytes scanned
- Create an authorized view that hides a salary column
- Set a maximum bytes billed on a query
Conclusion
BigQuery is a serverless SQL warehouse. Load data, query with standard SQL, partition and cluster to cut cost, choose on-demand or capacity pricing and secure data with IAM, authorized views and policy tags.
Quick Summary: what; first queries; loading; partition; pricing; cost control; access; features.

