how to set a limit on running time of a query in snowflake

Viewed 87

I'm looking for a way to limit the max running time of a query on snowflake server. is there any way to do so. like if a query can only run upto 30 minutes and after that snowflake send a notification alert.

1 Answers

You can try the parameter STATEMENT_TIMEOUT_IN_SECONDS which controls the duration of a query before canceling it. The default value is 172800 seconds(2 days). The query will quit after reaching the set limit.

You can try to programmatically query the query_history() view periodically for long-running queries to get an email notification

You can make use of the resource monitors

https://docs.snowflake.com/en/user-guide/resource-monitors.html#resource-monitor-notifications https://docs.snowflake.net/manuals/user-guide/resource-monitors.html

You can write scripts using snowsql and schedule through a crontab to send the reports as required.

Related