Say this first: system.query.history has the statement text, duration, and bytes scanned, so you can rank the warehouse's queries by what they actually cost to run.
Remember these
- system.query.history stores statement text, user, duration, and bytes
- Rank one warehouse's statements to find the one that grew
- The query profile then explains why that statement is expensive
- Filter on the time column or the history table itself is a large scan
Why: Warehouse size explains the rate, not the cause. system.query.history records each statement against a SQL warehouse: the text, the user, the warehouse id, total_duration_ms, and the bytes read. Sorting a single warehouse by duration or bytes over the week usually surfaces one dashboard query or a SELECT * that started scanning far more after a table grew. Cross-check the query profile for that statement to see whether it was a cache miss, a join explosion, or a full scan. Billing usage confirms the warehouse's DBU total; query history tells you which statement to fix. Filter on the start time or you will scan the whole history table.
SELECT user_name, total_duration_ms, read_bytes, statement_text
FROM system.query.history
WHERE compute.warehouse_id = :id
AND start_time >= current_timestamp() - INTERVAL 7 DAYS
ORDER BY total_duration_ms DESC
LIMIT 20
Senior depth: Unchanged SQL gets more expensive when the table underneath grows, loses clustering, or stops hitting the result cache because a non-deterministic function was added. Bytes scanned in query history is the column that distinguishes those from a warehouse that was simply busy.
Common mistake: Resizing the warehouse because the bill went up, without looking at which query changed.
Follow-up they will ask: The top query's text has not changed. What else could have made it slower?