0
0
GCPcloud~10 mins

BigQuery SQL and pricing model in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - BigQuery SQL and pricing model
Write SQL Query
Submit Query to BigQuery
BigQuery Scans Data
Calculate Data Processed (in bytes)
Apply Pricing Model
Return Query Results
Bill User Based on Data Processed
This flow shows how a SQL query is submitted to BigQuery, how data scanned is calculated, pricing applied, and results returned.
Execution Sample
GCP
SELECT name, age FROM `project.dataset.table` WHERE age > 30;
This SQL query selects names and ages from a table where age is greater than 30.
Process Table
StepActionData Scanned (GB)Pricing CalculationResult
1Submit SQL query0No cost yetQuery accepted
2BigQuery scans table data2.52.5 GB * $5 per TB = $0.0122Data scanned calculated
3Apply on-demand pricing2.5Cost = $0.0122Cost calculated
4Return query results2.5Cost charged to userResults delivered
5End2.5Billing completeQuery finished
💡 Query completes after scanning 2.5 GB, cost calculated and charged accordingly.
Status Tracker
VariableStartAfter Step 2After Step 3Final
Data Scanned (GB)02.52.52.5
Cost (USD)000.01220.0122
Key Moments - 3 Insights
Why does the cost depend on data scanned, not query complexity?
BigQuery charges based on the amount of data processed, not how complex the SQL is. See execution_table step 2 where data scanned is calculated first, then cost applied.
What happens if the query scans less data?
Cost decreases proportionally because pricing is per GB scanned. This is shown in execution_table step 3 where cost is calculated from data scanned.
Is the user billed before or after results are returned?
Billing happens after data scanned is calculated but before results are returned, as shown in execution_table steps 3 and 4.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the data scanned at step 2?
A2.5 GB
B0 GB
C5 GB
D1 GB
💡 Hint
Check the 'Data Scanned (GB)' column at step 2 in execution_table.
At which step is the cost calculated?
AStep 1
BStep 3
CStep 4
DStep 5
💡 Hint
Look at the 'Pricing Calculation' column in execution_table for when cost is computed.
If the data scanned was 5 GB instead of 2.5 GB, how would the cost change?
AIt would halve
BIt would stay the same
CIt would double
DIt would be zero
💡 Hint
Cost is proportional to data scanned as shown in execution_table step 3.
Concept Snapshot
BigQuery SQL queries scan data in tables.
Pricing is based on data scanned (GB), not query complexity.
On-demand pricing charges $5 per TB scanned.
Cost = Data scanned (GB) * $5 / 1024.
Results returned after billing calculation.
Optimize queries to scan less data to save cost.
Full Transcript
This visual execution shows how a BigQuery SQL query is processed and billed. First, the query is submitted. BigQuery scans the data needed to answer the query, measuring how many gigabytes are processed. Then, it calculates the cost based on the data scanned using the on-demand pricing model, which charges $5 per terabyte. After cost calculation, the query results are returned to the user. The user is billed based on the data scanned. This helps understand that cost depends on data volume scanned, not on how complex the SQL query is. Optimizing queries to scan less data reduces cost.