ANOMALY_ INSIGHTS!GET_ TOP_ QUERIES_ FROM_ WAREHOUSE¶
Returns the queries in a warehouse that consumed the most credits. Helps investigate account-level cost anomalies in the current account.
Syntax¶
Arguments¶
warehouse_idSpecifies the internal/system-generated identifier for the warehouse that ran the queries.
You can find the warehouse ID by calling the ANOMALY_INSIGHTS!GET_TOP_WAREHOUSES_ON_DATE method or querying the WAREHOUSE_METERING_HISTORY view.
Data type: NUMBER
'date'Specifies the date for which you want to return consumption data.
Data type: DATE
number_of_queriesLimits the number of queries returned by the method. For example, if you specify
5, the method returns only the top five queries in terms of credits consumed.Data type: NUMBER
Output¶
Returns a table with the following columns:
| Column name | Data type | Description |
|---|---|---|
| WAREHOUSE_NAME | VARCHAR | Name of the warehouse used to execute the query. |
| CONSUMPTION | NUMBER | Credits consumed by the query. |
| USERNAME | VARCHAR | User who executed the query. |
| QUERY_ID | VARCHAR | Query ID. |
| DURATION_MS | NUMBER | How long it took the query to execute, in milliseconds. |
| START_TIME | DATETIME | Date and time the user started executing the query. |
| QUERY_TAG | VARCHAR | Query tag, if any, applied to the query. |
Access control requirements¶
Users with any of the following roles can call this method:
- ACCOUNTADMIN system role
- GLOBALORGADMIN system role
- SNOWFLAKE.APP_USAGE_ADMIN application role
- SNOWFLAKE.APP_USAGE_VIEWER application role
Usage notes¶
- This method returns consumption data for the current account. It cannot be used to return data for other accounts or the entire organization.
- You cannot use this method to return a currency as the unit of measure for the consumption.
Example¶
Returns the top six queries that consumed the most credits on December 1, 2024, using a warehouse whose Warehouse ID is 838.