Alert Before Running Query Consisting Of Large Size Data

Viewed 36

Do we have any mechanism in Snowflake where we alert Users running a Query containing Large Size Tables , this way user would get to know that Snowflake would consume many warehouse credits if they run this query against large size dataset,

1 Answers

There is no alert mechanism for this, but users may run EXPLAIN command before running the actual query, to estimate the bytes/partitions read:

explain select c_name from "SAMPLE_DATA"."TPCH_SF10000"."CUSTOMER";

+-------------+----+--------+-----------+-----------------------------------+-------+-----------------+-----------------+--------------------+---------------+
|    step     | id | parent | operation |              objects              | alias |   expressions   | partitionsTotal | partitionsAssigned | bytesAssigned |
+-------------+----+--------+-----------+-----------------------------------+-------+-----------------+-----------------+--------------------+---------------+
| GlobalStats |    |        |           | 6585                              |  6585 | 109081790976    |                 |                    |               |
| 1           |  0 |        | Result    |                                   |       | CUSTOMER.C_NAME |                 |                    |               |
| 1           |  1 |      0 | TableScan | SAMPLE_DATA.TPCH_SF10000.CUSTOMER |       | C_NAME          |            6585 |               6585 |  109081790976 |
+-------------+----+--------+-----------+-----------------------------------+-------+-----------------+-----------------+--------------------+---------------+

https://docs.snowflake.com/en/sql-reference/sql/explain.html

You can also assign users to specific warehouses, and use resource monitors to limit credits on those warehouses.

https://docs.snowflake.com/en/user-guide/resource-monitors.html#assignment-of-resource-monitors

As the third alternative, you may set STATEMENT_TIMEOUT_IN_SECONDS to prevent long running queries.

https://docs.snowflake.com/en/sql-reference/parameters.html#statement-timeout-in-seconds

Related