Outcome: Read a query plan, identify the expensive operator, and cut a query's billed cost. Covers plan 100 wh-06.
1. Brief
Take the provided expensive query (cost_lab_expensive.sql: SELECT * over a
wide join with no partition filter). (a) Run EXPLAIN / dry-run and record
stages + bytes; (b) rewrite it (projection pushdown, partition filter, join
order / pre-aggregation); (c) show the before/after billed bytes.
2. Required deliverables
cost_cut.sql— original + rewritten query.evidence.md— EXPLAIN notes (which stage dominated) + before/after bytes.
3. Deterministic structural checks
no-select-star: rewritten query has an explicit column list.partition-filter: rewritten query filters on the partition column.cost-cut: rewritten bytes-billed <= 50% of original.
4. AI-review rubric
| Criterion | Weight | Pass bar |
|---|---|---|
| Plan reading | 40% | names the dominant stage and why it is expensive |
| Rewrite quality | 40% | all three structural checks green |
| Guardrail note | 20% | states a personal cost-control rule (validator-first, .dry-run, alerts) |