-
My goal: for each app, as we connect to snowflake we want to "ALTER SESSION SET QUERY_TAG='xxx'"
-
Issue: reporting on query load in snowflake is much more flexible if we can set up query_tag before each session gets going
-
Steps I've taken to troubleshoot:
We set up all queries Retool with a "debounce" of 100ms to 500ms... except for the inital one:
-- initial SQL:
alter session
set query_tag = 'Something_Distinct_Here'
We can see that statement happening in snowflake's query history... but there aren't a lot of queries running on that same session:
select * from snowflake.account_usage.query_history
where session_id = '2202076992122922';
All the meaningful queries are using a different session?
In snowflake we check it like so:
select session_id,count(*) from snowflake.account_usage.query_history
where user_name='DREAD_PIRATE_ROBERTS'
and start_time>'2025-04-24 14:20:00'
group by 1;
And we can see that there have been 43 sessions in the past hour
- Additional info: Retool Cloud
The snowflake connection is dynamic, and there are several dozen queries in the Retool app that leverage this connection. All other queries either have debounce > 100ms or are "manual".
Snowflake has object-level query tags and user-level query tags, but our structure would work much better with session-level query tags.
So are there any suggestions on how to set query_tag when an app starts up, for all the snowflake-sessions that are gonna be instantiated?