Skip to main content
All worked examplesAnalytics Engineer / dbt Specialist
Frugality (Amazon)

Refactoring 300+ Spaghetti SQL Models into Modular dbt: Slashing Snowflake Spend by $45,000/Month

Question: “Tell me about a time you optimized analytics infrastructure or data pipelines to achieve major cost savings and performance gains.”
Illustrative composite pattern — tailor it with your own project history.Adapt this question in Story Studio

1. Situation & Stakes

Rapid hiring of 20+ analysts had resulted in a chaotic warehouse environment with 300+ unversioned SQL transformation scripts running full table scans every hour. Monthly Snowflake compute costs surged from $28,000 to $78,000 in 6 months.

Scale & Timeline: 3-month optimization sprint; warehouse processing 1.8TB daily across 45 business domains with 800+ scheduled queries.
Business Risk: The VP of Engineering issued a mandate to slash data infrastructure spend by at least 40% or freeze future data hiring.

2. Task & Ownership Mandate

I took lead ownership of the warehouse refactoring project to migrate legacy cron-based SQL queries into a clean dbt Core DAG, eliminate duplicate computation, and optimize Snowflake warehouse sizing.

Success Criteria: Cut monthly Snowflake compute bill by >40% ($31K+/mo) and reduce 08:00 AM dashboard build latency by 50%.

3. Technical Action & Trade-Offs

  • Analyzed Snowflake `ACCOUNT_USAGE.QUERY_HISTORY` to profile the top 10% most expensive queries, finding that 12 upstream marketing models were recomputing the entire 3-year clickstream history hourly instead of incrementally.
  • Migrated 300 monolithic SQL scripts into a 3-tier dbt architecture (Staging $\rightarrow$ Intermediate $\rightarrow$ Marts) using ephemeral models and `is_incremental()` macros.
  • Configured Snowflake auto-clustering keys on high-cardinality transaction date and customer ID fields, eliminating 92% of partition micro-partition scanning.
  • Right-sized warehouse compute: segregated heavy hourly ETL onto dedicated 2XL warehouses with 60-second auto-suspend while moving ad-hoc BI exploration to auto-scaling Medium multi-cluster warehouses.
Key Architectural Trade-Offs
  • Implemented dbt Slim CI in GitHub Actions, ensuring pull requests only built modified models and their immediate downstream dependencies rather than running the full 300-model DAG.
  • Enforced dbt-expectations tests (`expect_table_row_count_to_be_between`, `expect_column_values_to_not_be_null`) on all Gold mart models.

4. Quantified Results

  • Slashed monthly Snowflake warehouse spend from $78,000 down to $33,000 (58% reduction, saving $540,000 annualized).
  • Reduced daily morning analytics build pipeline runtime from 135 minutes down to 34 minutes (75% faster execution).
  • Reduced average pull request CI build cost by 85% using dbt stateful deferral.

Business Impact: Surpassed the VP of Engineering’s cost target, unfreezing 4 headcount requisitions for the data team and earning an executive spot bonus.

5. Executive Reflection (Learning Agility)

  • Executive Hindsight: Early on, we prioritized rapid pipeline delivery over compute governance. Setting budget monitor caps at warehouse inception avoids retrospective six-figure FinOps overhauls.
  • Learning Agility: Realized that infrastructure cost optimization is a cultural habit. Pairing telemetry dashboards with automated Slack attribution creates sustainable developer accountability.
  • Systemic Impact: Established the dbt modeling standard and FinOps guidelines adopted by all 14 data analysts and analytics engineers across the department.

Interviewer Follow-Up Probes (Prepare for These Next)

  • Q1.How did you determine when to use incremental models vs. materialized tables vs. views in dbt?
  • Q2.How did you avoid data drift or late-arriving records in your incremental logic?
  • Q3.If a downstream dashboard broke during refactoring, what was your rollback mechanism?
Make It Authentic

Turn your own real project into this format

Never memorize someone else's story. Log your metrics in Karyika and synthesize an authentic, first-person STARR response.

Adapt in Story Studio