Snow Session

 What does it mean by Snow Session?

In snowflake session begins when user connects successfully using any programmatic client, Snow sight, CLI or classic console. As session is maintained with continued user activity. After a period of inactivity in the session, (idle session timeout) the user must authenticate again. In case of web UI, the session will remain constant. But when we perform any activity in Snow SQL (CLI)  


SELECT CURRENT_SESSION(); -- This will give you current session id;
SELECT LAST_QUERY_ID(); -- This will give you the last Query id.
SELECT CURRENT_WAREHOUSE(), CURRENT_DATABASE(), CURRENT_SCHEMA();

Snowflake Classic Console Sessions

In the Worksheets Worksheet tab tab, Snowflake creates a new session every time a new worksheet is created. Each worksheet is limited to a maximum of 4 hours of idle behavior, and the idle timeout for each worksheet is tracked separately.

When a worksheet is closed, the user session for the worksheet ends.

SnowSQL(CLI)  : 

Every query that you execute in SnowSQL(CLI) will have it's one session ID because it is extension to the Snowflake So each time when you run the a set of queries, it opens a session run the query and close the session. 

So it is better to write them as a package (Stored procidure / Task ) and run it .

When you run any number of queries in a singe work sheet will have only one session ID.

Reference for Session policy : https://docs.snowflake.com/en/user-guide/session-policies




Comments