Schemas:

ACCOUNT_USAGE , READER_ACCOUNT_USAGE

WAREHOUSE_METERING_HISTORY 视图

此 Account Usage 视图可用于返回过去 365 天(1 年)内单个仓库(或账户中的所有仓库)的每小时 credit 使用量。

Column NameData TypeDescription
READER_ACCOUNT_NAMEVARCHARName of the reader account where the warehouse usage took place. Column only included in view in READER_ACCOUNT_USAGE schema.
START_TIMETIMESTAMP_LTZThe date and beginning of the hour (in the local time zone) in which the warehouse usage took place.
END_TIMETIMESTAMP_LTZThe date and end of the hour (in the local time zone) in which the warehouse usage took place.
WAREHOUSE_IDNUMBERInternal/system-generated identifier for the warehouse.
WAREHOUSE_NAMEVARCHARName of the warehouse.
CREDITS_USEDNUMBERTotal number of credits used for the warehouse in the hour. This is a sum of CREDITS_USED_COMPUTE and CREDITS_USED_CLOUD_SERVICES. This value does not take into account the adjustment for cloud services, and may therefore be greater than the credits that are billed. To determine how many credits were actually billed, run queries against the METERING_DAILY_HISTORY view.
CREDITS_USED_COMPUTENUMBERNumber of credits used for the warehouse in the hour.
CREDITS_USED_CLOUD_SERVICESNUMBERNumber of credits used for cloud services in the hour.
CREDITS_ATTRIBUTED_COMPUTE_QUERIESNUMBERNumber of credits attributed to queries in the hour.

Includes only the credit usage for query execution and doesn’t include warehouse idle time usage.

使用说明

  • In the ACCOUNT_USAGE schema, latency for the view is up to 180 minutes (3 hours), except for the CREDITS_USED_CLOUD_SERVICES column. Latency for CREDITS_USED_CLOUD_SERVICES is up to 6 hours.

  • 在 READER_ACCOUNT_USAGE 架构中,视图的延迟时间最长可达 24 小时。

  • 仓库闲置时间不包括在 CREDITS_ATTRIBUTED_COMPUTE_QUERIES 列中。

    See Examples for a query that calculates the cost of idle time.

  • The CREDITS_ATTRIBUTED_COMPUTE_QUERIES column is NULL for adaptive warehouses.
  • If you want to reconcile the data in this view with a corresponding view in the ORGANIZATION USAGE schema, you must first set the timezone of the session to UTC. Before querying the Account Usage view, execute:

    ALTER SESSION SET TIMEZONE = UTC;

示例

例如,要确定过去 10 天内每个仓库的空闲时间成本,请执行以下语句:

SELECT
  (SUM(credits_used_compute) -
    SUM(credits_attributed_compute_queries)) AS idle_cost,
  warehouse_name
FROM SNOWFLAKE.ACCOUNT_USAGE.WAREHOUSE_METERING_HISTORY
WHERE start_time >= DATEADD('days', -10, CURRENT_DATE())
  AND end_time < CURRENT_DATE()
GROUP BY warehouse_name;