CTE Cost Breakdown
Analyze cost per CTE to identify expensive query parts.
Breakdown Display
Total Cost: $0.045 (9 GB processed)
CTE Breakdown:
┌─────────────────┬──────────┬───────────┬────────┐
│ CTE Name │ Cost │ Data │ % Cost │
├─────────────────┼──────────┼───────────┼────────┤
│ raw_data │ $0.025 │ 5 GB │ 55.5% │
│ user_summary │ $0.015 │ 3 GB │ 33.3% │
│ active_users │ $0.005 │ 1 GB │ 11.2% │
└─────────────────┴──────────┴───────────┴────────┘
Optimization Priority
| % of Cost | Priority |
|---|---|
| 50%+ | High - optimize first |
| 20-50% | Medium - review |
| Under 20% | Low - skip unless easy |
Common Patterns
Expensive Initial CTE
Problem: Full table scan in first CTE, filter applied later Solution: Move WHERE filter into the CTE
Data Explosion
Problem: UNNEST creates 50x more rows than input Solution: Filter before UNNEST
Redundant CTEs
Problem: CTE just passes through data unchanged Solution: Merge into next CTE
Too Many Columns
Problem: SELECT * when only 2 columns needed Solution: Select only needed columns
Filter Propagation
Querylab.io replicates BigQuery's optimization to show realistic estimates.
Works: Simple comparisons, equality, IN, AND combinations
Doesn't work: Aggregation filters, window functions, OR combinations