Worked Example: 10x Cost Cut
Concepts covered: Pipeline Monitoring
analytics.sessions_enriched builds user sessions from raw click events. At $40,000 a month it tops the cost rollup, and its spend grew 40% in 6 months while the team grew 10%. The owner team runs a cost pass in 3 stages: read lineage, pull the levers in order, and verify each change against the observability pillars before the next.
| Component | How it runs | Monthly cost |
|---|---|---|
| Transform | Full rebuild of 36 months, hourly: 720 runs at $40 | $28,800 |
| Consumer queries | Six readers query a 140-column unpartitioned table | $7,200 |
| Storage | Raw events for 36 months plus 30 kept copies of the output | $2,800 |
| Dev and CI | Full-volume clones rebuilt nightly | $1,200 |
| Total | $40,000 |
Stage 1: read lineage before changing anything
| Reader | Reads | Needs data by | Queries in 90 days, excluding auto-refresh |
|---|---|---|---|
| Exec revenue dashboard | Daily | 06:00 UTC | 2,100 |
| Marketing attribution job | Daily | 06:00 UTC | 90 |
| ML feature job | Daily | 05:00 UTC | 90 |
| Ops live dashboard | Hourly | Today, within 1 hour | 8,400 |
| Legacy funnel dashboard | Every 15 minutes | No SLA | 0 |
| Retention test dashboard | Every 15 minutes | No SLA | 0 |
Of the 6 readers, 2 dashboards refresh every 15 minutes and have had no human queries in 90 days, and 3 readers look once a day. Only the ops dashboard needs data within the hour, and only for today. An hourly rebuild of 36 months exists to serve 1 reader's need for 1 day of data.
Stage 2: pull the levers in order
| Lever | Change | Monthly total after |
|---|---|---|
| Stop doing it | Retire the 2 unread dashboards, saving $4,800 in queries; delete the 30 output copies, saving $1,200, since snapshots already keep 7 days | $34,000 |
| Run less often | Full build moves to daily at 04:00 UTC; a small hourly job writes only today's partition, at $1.50 a run | $7,480 |
| Recompute less | The daily build rewrites the last 3 days, the late-data window, instead of 36 months: $40 a run becomes $12 | $6,640 |
| Scan less | Output partitioned by event date; builds and readers select 22 of 140 columns; dev and CI use a 1% key sample | $4,020 |
| Pay less per unit | Cluster shrinks from 32 to 8 nodes; runs take longer but cost $8 daily and $0.75 hourly | $3,780 |
Run less often removed $26,520, the largest share, because no reader needed what hourly full rebuilds produced. Scan less shrank each daily run from $12 to $10 and each hourly run from $1.50 to $1.00, halved the readers' query bill to $1,200, and cut dev and CI to $200. Storage settled at $1,600 because raw events stay for 36 months under the retention policy. Pay less per unit came last because it tunes a job every earlier lever had already shrunk.
Another team copies this pass for a pipeline whose only reader is a fraud model that scores each payment within 2 minutes of the event. Which lever is ruled out by the reader's needs before any cost data is pulled?
- Scan less, because a fraud model reads every column on each score.
- Stop doing it, because a single reader means nobody depends on it.
- Pay less per unit, because a smaller cluster always misses 2 minutes.
- Run less often, because a 2-minute freshness need sets the cadence floor.
- raw_click_events (bronze, event lake, 36 months)
- hourly_today_job (transform, orchestrator); freshness: 1 hour; parallelism: 8 nodes; retries: 3; idempotency: overwrite today's partition
- daily_window_build (transform, orchestrator); freshness: 04:30 UTC; parallelism: 8 nodes; retries: 3; backfill: rewrite last 3 days; idempotency: partition overwrite
- pillar_checks (quality gate, freshness, volume, schema, distribution); on error: block publish; alerting: page owner team
- sessions_enriched (gold, partitioned by event_date)
- exec_revenue_dashboard (consumer, dashboard)
- attribution_job (consumer, batch job)
- ml_feature_job (consumer, batch job)
- ops_live_dashboard (consumer, dashboard)
- raw_click_events -> hourly_today_job
- raw_click_events -> daily_window_build
- hourly_today_job -> pillar_checks
- daily_window_build -> pillar_checks
- pillar_checks -> sessions_enriched
- sessions_enriched -> exec_revenue_dashboard
- sessions_enriched -> attribution_job
- sessions_enriched -> ml_feature_job
- sessions_enriched -> ops_live_dashboard
- Raw: raw_click_events
- Build: hourly_today_job, daily_window_build
- Gate: pillar_checks
- Serving: sessions_enriched
- Readers: exec_revenue_dashboard, attribution_job, ml_feature_job, ops_live_dashboard
Stage 3: verify with the 5 pillars
Each lever shipped as a shadow build first: the new logic wrote analytics.sessions_enriched_v2 for 7 days beside the old table, and readers switched only after the comparison passed. A cost cut that changes the numbers is a data incident with a smaller bill.
| Pillar | What was checked | Pass condition |
|---|---|---|
| Freshness | Daily build finish time; lag of today's partition | Daily done by 04:30 UTC; today under 1 hour behind |
| Volume | Sessions per event date, old versus v2 | Exact match for days older than 3 days |
| Schema | Names and types of the 22 columns readers select | No change |
| Distribution | Median session length, null rate of `user_id`, sessions by country | Within 1% of the old table each day |
| Lineage | Query log on retired tables; reader job status | Zero reads of retired tables, zero reader failures |
WITH before_cut AS (
SELECT
event_date,
count(*) AS sessions
FROM analytics.sessions_enriched
WHERE event_date >= DATE '2026-10-01'
GROUP BY
event_date
),
after_cut AS (
SELECT
event_date,
count(*) AS sessions
FROM analytics.sessions_enriched_v2
WHERE event_date >= DATE '2026-10-01'
GROUP BY
event_date
)
SELECT
coalesce(b.event_date, a.event_date) AS event_date,
b.sessions AS old_sessions,
a.sessions AS v2_sessions
FROM before_cut AS b
FULL OUTER JOIN after_cut AS a
ON b.event_date = a.event_date
WHERE b.sessions IS DISTINCT FROM a.sessions
ORDER BY
event_dateOn the last shadow day the query returned 2 rows, the 2 most recent days. That is expected: the old table rebuilt every hour and had already absorbed late events that v2 picks up at its next 04:00 run. A mismatch on any day older than 3 days would mean events arriving outside the late-data window, and the switch would have waited until the window was widened and the run cost recalculated.
- 10.6x
- $36,220
- 0
The rollup shows sessions_enriched at $9,300 a month, 6 weeks after the switch. It ran 1,440 times last month, and each kind of run costs what it did after the pass. What happened, and where does it surface first?
- Reader queries grew, and the volume pillar flags it on the next check.
- The daily build was rescheduled hourly, and week 1's growth ranking flags it.
- The cluster went back to 32 nodes, and the freshness pillar catches it.
- Late events widened the window, and the distribution pillar catches it.
About this lesson
This section is part of the Pipeline Operations: Advanced lesson on DataDriven, the home of data engineering. Lessons cover SQL, Python, Spark, data modeling and pipeline architecture, and each section pairs its explanation with worked examples and practice you run as you go.