Query Insights
The Insights feature set (introduced in v0.2.0) gives you a deeper understanding of which query patterns are driving Snowflake spend, how that spend has changed, and what to do about it — all without writing SQL yourself.
Query fingerprinting
FrostWatch normalizes every query in your history to a canonical form:
- Strip
--and/* */comments - Replace string literals with
'?' - Collapse
IN (...)value lists toIN (?) - Replace numeric literals with
? - Collapse whitespace and uppercase
The result is an MD5 fingerprint that groups queries that differ only in bind values or formatting into a single pattern. For example, these three queries all map to the same fingerprint:
SELECT * FROM orders WHERE id = 123
SELECT * FROM orders WHERE id = 456
SELECT * FROM orders WHERE id = 789
The Insights → Fingerprints page shows the top patterns by total credits, with per-pattern stats: total and average credits, execution count, first/last seen, and the most frequent warehouse and user.
API endpoint: GET /api/insights/fingerprints?days=30&limit=20
Week-over-week regression detection
FrostWatch compares the average credits per execution for each fingerprint between the current week and the previous week. Patterns that grew beyond a configurable threshold are flagged with a severity label:
| Ratio (this week / last week) | Severity |
|---|---|
| 2× – 2.9× | medium |
| 3× – 4.9× | high |
| ≥ 5× | critical |
This catches situations where a query hasn't changed in code but is suddenly scanning much more data — a sign of missing filters, table bloat, or clustering drift.
API endpoint: GET /api/insights/regressions?threshold=2.0&limit=10
Cost forecasting
FrostWatch fits an ordinary least-squares regression to each warehouse's daily credit history and projects forward. Each forecast point includes:
- Predicted credits and USD cost for each future day
- Trend —
up,down, orstable(based on the regression slope) - Confidence —
low(fewer than 7 data points),medium(7–13), orhigh(14+) - Projected 30-day totals — helpful for budget planning
Forecasts use the credits_per_dollar value from your config (default: 3.0).
API endpoint: GET /api/insights/forecasts?days_ahead=7&history_days=30
AI query rewrites
Submit any query ID to get an LLM-generated optimization report. The report includes:
- Rewrite — optimized SQL with inline comments explaining each change
- Root Cause — why the original query is expensive (1–2 sentences)
- Recommendations — clustering keys, filter pushdowns, warehouse right-sizing (bullet list)
- Estimated Savings — rough credit reduction as a percentage range
Rewrite results are persisted and returned idempotently — calling the endpoint again for the same query ID returns the cached result without a second LLM call.
LLM required
AI rewrites require a configured LLM provider (llm_provider + llm_api_key in your config). Run frostwatch demo to see pre-baked example rewrites without an API key.
API endpoints:
POST /api/insights/rewrites { "query_id": "01b2c3d4-..." }
GET /api/insights/rewrites/{id} Fetch a previously generated rewrite
Partition pruning analysis
Snowflake stores data in micro-partitions. When a query has good clustering key alignment, Snowflake prunes (skips) partitions that cannot contain matching rows. A query that scans 95 % of partitions is performing a near-full-table-scan — usually fixable with a clustering key or a better WHERE filter.
FrostWatch computes the pruning ratio (partitions_scanned / partitions_total) for every query that has partition metadata, groups results by SQL fingerprint, and surfaces patterns where the average ratio is high and the credit cost is significant.
| Avg pruning ratio | Severity |
|---|---|
| 50 % – 69 % | medium |
| 70 % – 89 % | high |
| ≥ 90 % | critical |
Each result includes a tailored recommendation (add a clustering key, push selective filters earlier, etc.) and the average/total credits consumed so you can prioritise fixes by ROI.
Small tables are excluded
Tables with fewer than 100 average partitions are excluded by default — full scans on small tables are cheap and not worth the noise. Adjust the min_partitions query parameter to raise or lower this threshold.
API endpoint: GET /api/insights/pruning?days=30&limit=20&min_partitions=100&min_ratio=0.5
Demo mode
frostwatch demo pre-seeds two realistic rewrite examples — an ML features query and a MERGE statement — so the Insights page is immediately populated when you try the demo. No LLM API key required.