Data Modeling & Warehousing Fundamentals
Back to Modern Warehouse Engines & Performance

LAB: Cost Control + EXPLAIN — Cut a Query's Cost

Plan 100 W8 wh-06: read a plan and cut a query's billed cost.

61 minutesProject submission
🎯 Free Guest Mode: You are learning for free. Sign in to save your completion progress and quiz answers.

Assignment Instructions

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

  1. cost_cut.sql — original + rewritten query.
  2. 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

CriterionWeightPass bar
Plan reading40%names the dominant stage and why it is expensive
Rewrite quality40%all three structural checks green
Guardrail note20%states a personal cost-control rule (validator-first, .dry-run, alerts)
Checking your access…