All of the information below can be obtained from:
https://docs.snowflake.com/en/sql-reference/account-usage.html
Prerequisites:
Requires AccountAdmin role to access account_usage schema.
use database snowflake;
use schema account_usage;
Credits used by each warehouse in your account (month-to-date):
select warehouse_name, sum(credits_used) as total_credits_used from warehouse_metering_history where start_time >= date_trunc(month, current_date) group by 1 order by 2 desc;
Credits used over time by each warehouse in your account (month-to-date):
select start_time::date as usage_date, warehouse_name, sum(credits_used) as total_credits_used from warehouse_metering_history where start_time >= date_trunc(month, current_date) group by 1,2 order by 2,1;
Examples: Data Storage Usage
Billable terabytes stored in your account over time:
select date_trunc(month, usage_date) as usage_month , avg(storage_bytes + stage_bytes + failsafe_bytes) / power(1024, 4) as billable_tb from storage_usage group by 1 order by 1;
Examples: User Query Totals and Execution Times
Total jobs executed in your account (month-to-date):
select count(*) as number_of_jobs from query_history where start_time >= date_trunc(month, current_date);
Total jobs executed by each warehouse in your account (month-to-date):
select warehouse_name, count(*) as number_of_jobs from query_history where start_time >= date_trunc(month, current_date) group by 1 order by 2 desc;
Average query execution time by user (month-to-date):
select user_name, avg(execution_time) as average_execution_time from query_history where start_time >= date_trunc(month, current_date) group by 1 order by 2 desc;
Average query execution time by query type and warehouse size (month-to-date):
select query_type, warehouse_size, avg(execution_time) as average_execution_time from query_history where start_time >= date_trunc(month, current_date) group by 1,2 order by 3 desc;