1. Meet BigQuery: store big tables, ask with SQL
1.2 What a query costs: pay for what you read
Highlights & notes
Select lesson text to highlight it, or tap Add note.
Bookmarks
Bookmark a lesson to see it here.
Imagine a library that charges by how many pages you open, not by how long you sit there. BigQuery works like that. It charges for the bytes it reads to answer your query. This is called on-demand pricing.
- The price is about $6.25 for each TiB read. A TiB is a little more than 1,000 GB.
- The first 1 TiB every month is free.
- For storage, the first 10 GiB is free.
- A query that fails costs nothing. A query answered from the cache costs nothing.
Before you run a query, look at the top right of the editor. BigQuery writes "This query will process 12 MB when run". This check is called a dry run and it is free. Read it every time.
Three ways to read less
- Name your columns:
SELECT order_id, amount, notSELECT * - Filter on the partition column (next chapter)
- Use the Preview tab to look at rows. Preview is free.
SELECT * ... LIMIT 10is not.
LIMIT 10 does not make a query cheaper on a normal table. BigQuery reads the whole column first and only then shows you 10 rows.
How it fits together
- You write SQL
- Dry run: bytes to read
- Run: pay for those bytes
Same table, two bills
Here the orders table is 10 GB: ten columns of about 1 GB each.
SQL
SELECT *FROM sales.orders;SELECT order_id, amountFROM sales.ordersLIMIT 10;
Result
Query 1 reads 10 GB Query 2 reads 2 GB LIMIT 10 saved 0 GB
Try it yourself
1. Type SELECT * FROM sales.orders in the editor. Do not run it. Read the bytes shown at the top right.
2. Change it to SELECT order_id, amount FROM sales.orders. The number drops.
3. Add LIMIT 2. The number does not change.
Question 1 · Easy
With on-demand pricing, what does BigQuery charge a query for?
Question 2 · Medium
Which query reads the least data from a 50-column table?
Question 3 · Hard
The editor says "This query will process 900 GB". What is the smartest next step?
Key takeaways
On-demand BigQuery charges for bytes read: about $6.25 per TiB, with 1 TiB free each month. Read the dry-run number before you run. Name your columns. LIMIT does not cut the bill.
Save your progress
Start free and your progress, code and notes stay saved. Free for 1 month, no card needed.
Start free Log in