Free tool · Snowflake
Audit a Snowflake CSV export, privately, in your browser
Run one query on your account's usage history, download the result as CSV and choose the file below. This page works out the last 30 days of compute credits by user, dbt model and dashboard, the days that spiked, and the 20 most expensive queries with fix hints — without an account, a credential, or the file leaving your computer.
What it prices, and what it does not
- Compute credits attributed to each query:
credits_attributed_computefrom QUERY_ATTRIBUTION_HISTORY, at a price per credit: 3 USD by default, the Enterprise edition list price on AWS US. Other editions, regions and contracts differ; type yours below. - Not idle warehouse time. QUERY_ATTRIBUTION_HISTORY leaves out very short queries and the time a warehouse runs with nothing on it, so the total here is lower than compute on the invoice. Add the optionalwarehouse-metering export to see by how much, day by day and warehouse by warehouse.
- Not cloud services, storage or data transfer, which are billed separately.
1. Export the query history
SELECT a.query_id, TO_VARCHAR(a.start_time, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZH:TZM') AS start_time, a.user_name, a.warehouse_name, a.warehouse_id, q.query_type, LEFT(q.query_text, 20000) AS query_text, a.query_tag, q.bytes_scanned, a.credits_attributed_compute, q.total_elapsed_time, q.bytes_spilled_to_remote_storage, q.partitions_scanned, q.partitions_total FROM snowflake.account_usage.query_attribution_history a LEFT JOIN snowflake.account_usage.query_history q ON q.query_id = a.query_id AND q.start_time >= DATEADD(day, -31, CURRENT_TIMESTAMP()) WHERE a.start_time >= DATEADD(day, -30, CURRENT_TIMESTAMP())
- Run it in a Snowsight worksheet, on any warehouse. It reads
SNOWFLAKE.ACCOUNT_USAGE, which needs ACCOUNTADMIN or a role granted the SNOWFLAKE database rolesUSAGE_VIEWER(for QUERY_ATTRIBUTION_HISTORY) andGOVERNANCE_VIEWER(for QUERY_HISTORY). It is a query like any other, billed to that warehouse. - Download the results as CSV from the results pane.
- One account per export. Snowflake attributes credits to queries up to eight hours late, so the most recent hours may be missing.
2. Choose the file
An export made with the Snowflake query on /audit works too: it is the same query.
3. Optional: why does warehouse compute exceed query cost?
Snowflake bills a warehouse for every second it runs, whether or not a query is running on it.WAREHOUSE_METERING_HISTORY records what each warehouse metered; QUERY_ATTRIBUTION_HISTORY — the export above — splits part of that across the queries that ran. The two never quite agree, and the difference is the compute no query carries. A second export, of the metering, sets them side by side, in this page.
The formula
Unattributed compute = metered compute − credits attributed to queries, by UTC day and warehouse.
It splits in two using Snowflake's own hourly figure, CREDITS_ATTRIBUTED_COMPUTE_QUERIES:idle, per Snowflake = metered − that figure; not in the query export = that figure − the export's credits.
- Metered:
CREDITS_USED_COMPUTEfrom WAREHOUSE_METERING_HISTORY, summed by UTC day — the warehouse's compute, idle time included. Not cloud services. - Attributed:
credits_attributed_computefrom the query export, summed by the UTC day each query started and its warehouse. - Idle, per Snowflake: time the warehouse ran with no query to charge it to — waiting out its auto-suspend, or kept running. Snowflake's documentation estimates idle cost the same way. To see how a different delay would change it, model two settings with the auto-suspend calculator.
- Not in the query export: credits Snowflake attributed to queries that the export does not have — rows it rejected, rows cut off, or attribution that had not arrived when it was run. It is a coverage problem, and the page says so, rather than counting it as idle time.
- USD: credits × the credit price in step 2. Type your contract rate there; it is an estimate, not an invoice.
Unattributed compute is not the same as waste. Attribution can be up to 8 hours late, very short queries (around 100 ms or less) and adaptive warehouses are left out of it, and a query that runs across midnight is counted on the day it started. Some idle time is the cost of a warehouse being ready. What this shows is where to look, not what you would save. Cloud services, storage, data transfer and serverless features are billed separately and are in neither export, so they are outside every total here.
SELECT
TO_VARCHAR(TO_DATE(CONVERT_TIMEZONE('UTC', start_time)), 'YYYY-MM-DD') AS day,
warehouse_id,
warehouse_name,
SUM(credits_used_compute) AS credits_used_compute,
IFF(COUNT(*) = COUNT(credits_attributed_compute_queries),
SUM(credits_attributed_compute_queries), NULL) AS credits_attributed_compute_queries,
TO_VARCHAR(CONVERT_TIMEZONE('UTC', CURRENT_TIMESTAMP()), 'YYYY-MM-DD"T"HH24:MI:SS"Z"') AS exported_at
FROM snowflake.account_usage.warehouse_metering_history
WHERE start_time >= DATEADD(day, -32, CURRENT_TIMESTAMP())
AND TO_DATE(CONVERT_TIMEZONE('UTC', start_time))
>= DATEADD(day, -30, TO_DATE(CONVERT_TIMEZONE('UTC', CURRENT_TIMESTAMP())))
AND TO_DATE(CONVERT_TIMEZONE('UTC', start_time))
< TO_DATE(CONVERT_TIMEZONE('UTC', CURRENT_TIMESTAMP()))
GROUP BY 1, 2, 3
ORDER BY 1, 3- Run it in the same account, straight after the query export above, and download the results as CSV. It reads
WAREHOUSE_METERING_HISTORY, which the sameUSAGE_VIEWERrole can read. - Dates: it adds metering up by UTC day, for the 30 whole UTC days before today. The query export starts and ends partway through a day, so its first and last UTC days are left out, and only days both exports cover in full are compared. Run both after 8:00 UTC, or yesterday is left out too, because its attribution may still be arriving.
- Warehouses are matched by
warehouse_id, which both exports carry, so a warehouse renamed during the month is still one warehouse. An older query export without that column is matched by name, and a warehouse dropped and created again under the same name is then left out and said to be.
The synthetic example is a made-up pair of exports — three fictional warehouses over eight days — loaded into both steps.
Keep it up to date
This is one export, one time. Connected with a read-only account, dwhat reads the history every few hours, adds idle warehouse time from metering, emails you when a day costs much more than usual, and builds a monthly report for finance.