Data Warehouse Query Cost Optimization Analysis Builder
Analyze warehouse query logs and billing data to find expensive dashboards, models, users, schedules, and SQL patterns, then prioritize safe cost optimizations.
Prompt Template
You are an analytics engineering lead. Build a data warehouse query cost optimization analysis for: **Warehouse:** [BigQuery, Snowflake, Redshift, Databricks, Postgres analytics replica] **Billing model:** [bytes scanned, warehouse credits, compute clusters, slots, storage plus compute] **Time period:** [date range] **Available logs:** [query text, user, role, warehouse, dashboard, model, bytes scanned, duration, credits/cost, schedule time, success/failure] **Workloads:** [BI dashboards, dbt models, notebooks, reverse ETL, ad hoc analysis, product analytics] **Known pain:** [monthly bill spike, slow dashboards, runaway jobs, duplicate models, leadership cost target] **Constraints:** [must preserve SLAs, compliance retention, executive dashboards, data freshness] Produce a cost analysis with: 1. **Spend baseline** — daily/weekly cost trend, forecasted monthly run rate, and change vs prior period. 2. **Top cost drivers** — queries, dashboards, models, users, roles, warehouses, schedules, and tables. 3. **Cost per business object** — estimate cost per dashboard, data product, team, or KPI where possible. 4. **SQL and modeling anti-patterns** — unbounded dates, SELECT *, cross joins, repeated CTE scans, excessive refreshes, missing clustering/partition pruning, oversized warehouses. 5. **Freshness vs cost tradeoff** — which jobs can run less often, incrementally, or only on business days. 6. **Quick wins** — low-risk changes with estimated savings and owners. 7. **Structural changes** — materialized views, incremental models, aggregate tables, semantic layer caching, warehouse sizing, retention policies. 8. **SQL/log queries** — example queries to reproduce the analysis. 9. **Risk assessment** — what could break and how to roll back safely. 10. **Executive memo** — savings target, timeline, dependencies, and next review cadence. Do not recommend blind cost cutting; preserve trusted reporting and document expected freshness changes.
Example Output
# Warehouse Cost Optimization Analysis: BigQuery
Baseline
Monthly run rate increased from €7,900 to €11,600. The top 20 query patterns account for 61% of scanned bytes, and 38% of cost is generated by scheduled BI refreshes before 8 AM.
Top Findings
1. The `orders_explore` dashboard refreshes every 15 minutes but is viewed by executives twice per day. Reducing refresh to hourly saves an estimated €840/month.
2. A dbt model scans the full `events` table daily because the date filter is applied after a join. Converting to incremental partitioned logic saves roughly €1,450/month.
3. Three analyst notebooks run near-identical customer segmentation queries. A shared aggregate table would reduce repeated scans.
Priority Actions
| Action | Owner | Risk | Est. Monthly Savings |
|---|---|---|---:|
| Make `fct_events_daily` incremental | Analytics Eng | Medium | €1,450 |
| Reduce dashboard auto-refresh frequency | BI Lead | Low | €840 |
| Add partition filter guardrail in review checklist | Data Platform | Low | €500 |
Rollback
Keep old model definitions for seven days and compare row counts, KPI deltas, and dashboard load times before deleting legacy tables.
Tips for Best Results
- 💡Start with query logs and billing data together; slow queries are not always the most expensive ones.
- 💡Estimate savings before making changes, then verify after deployment with a fresh billing window.
- 💡Protect executive and regulatory reporting from surprise freshness changes.
- 💡Turn recurring cost issues into review rules for dashboards, dbt models, and notebooks.
Related Prompts
Dataset Summary and Insights
Paste or describe a dataset and get an instant summary of key statistics, patterns, anomalies, and actionable insights.
SQL Query Writer for Business Reports
Generate SQL queries for common business reporting needs — revenue trends, cohort analysis, funnel metrics, and more.
Dashboard KPI Definition Framework
Define the right KPIs for your business dashboard with clear formulas, targets, and data sources.