Snowflake Virtual Warehouse, Storage, and Cloud Services Usage

To Nha Notes | Oct. 25, 2022, 12:14 p.m.

Viewing Warehouse Credit Usage for Your Account

Users with the ACCOUNTADMIN role can use Snowsight, the classic web interface, or SQL to view monthly and daily credit usage for all the warehouses in your account.

Note

Keep in mind that credits are consumed based on warehouse size, number of clusters per warehouse (for multi-cluster warehouses), and the length of time each cluster runs.

How to Find out Where Your Cloud Services Usage is Coming From

Query History

Example: Find queries by type that consume the most cloud services credits

-- The current role must have access to the account usage share
use schema snowflake.account_usage;

select query_type, sum(credits_used_cloud_services) cs_credits, count(1) num_queries
from query_history
where true
and start_time >= timestampadd(day, -1, current_timestamp)
group by 1
order by 2 desc
limit 10;

Example: Find queries of a given type that consume the most cloud services credits

-- The current role must have access to the account usage share
use schema snowflake.account_usage;

select *
from query_history
where true
  and start_time >= timestampadd(day, -1, current_timestamp)
  and query_type = 'COPY'
order by credits_used_cloud_services desc
limit 10;

Example: Sort by different components of cloud services usage

-- The current role must have access to the account usage share
use schema snowflake.account_usage;

select *
from query_history
where true
  and start_time >= timestampadd(minute, -60, current_timestamp)
  and query_type = 'COPY'   --- optional
order by compilation_time desc,
               execution_time desc,
               list_external_files_time desc,
               queued_overload_time desc,
               credits_used_cloud_services desc
limit 10;

Warehouse History

Example: Find warehouses that consume the most cloud services credits

-- The current role must have access to the account usage share
use schema snowflake.account_usage;

select warehouse_name,
       sum(credits_used_cloud_services) credits_used_cloud_services,
       sum(credits_used_compute) credits_used_compute,
       sum(credits_used) credits_used
from warehouse_metering_history
where true
  and start_time >= timestampadd(day, -1, current_timestamp)
group by 1
order by 2 desc
limit 10;

 

References

https://docs.snowflake.com/en/user-guide/credits.html

https://docs.snowflake.com/en/user-guide/ui-snowsight-gs.html#signing-in-to-web-interface