It may seem like a small piece of information, but the query id can be quite useful in several contexts. I thought I’d share a few details about the query id, how to find it, and how to use it.
Query ID
Every query run within Snowflake is assigned a query id. These query ids can be used by support or other groups within Snowflake to uniquely identify a single instance of execution of a query. This means that if you have a problem and need to open a support ticket, it can be supremely helpful to have query_ids for related queries, even if those queries are beyond the 14 days of history that are visible.
A query id looks something like this:
01b71944-0001-b181-0000-0129032279f6
Snowflake does not publish about how query ids are generated and therefore there is no guarantee that much I say about them here will hold still. If you’re reading this blog entry more than 10 minutes after I publish it, they could have changed how things are done. For the most part, the first leading characters are based in a date/time indicator, and therefore nearly every query id you will see right now starts with 01.
Finding a Query ID
Workspaces
I’m a fan of the newish workspaces, so this is my default way of interacting with Snowflake right now.
To find a query id when working in workspaces, simply expand the query history pane at the bottom if it is not already visible. Either hover over or click on a row for the icons to appear on the far right. Click on the copy icon to copy the query id.
![]()
Worksheets
When running a query in a worksheet, the query id is displayed on the bottom right pane, next to the results. Hover here, and there is a copy button you can use to copy the query id.

LAST_QUERY_ID
In notebooks and other interfaces where the query id is not immediately displayed, you can use the LAST_QUERY_ID function to find the id of the last query. Here is what that looks like in a notebook:

This can be used in other interfaces as well, to get the query id in a programmatic way. Some interfaces may add queries in between that you’re not aware of. you can also specify a number in the LAST_QUERY_ID function to get ids from the query before the last one and so on backward. Check out the documentation on LAST_QUERY_ID for more information.
Query History
The ACCOUNT_USAGE.QUERY_HISTORY view and INFORMATION_SCHEMA.QUERY_HISTORY() table functions also contain the query id. You can also access this information from the query history option on the monitoring menu in Snowsight.

Query history information is generally available in the ACCOUNT_USAGE.QUERY_HISTORY view for 14 days after query execution. If using hybrid tables, not all query ids may be listed in query history.
Using a Query ID
As mentioned before, the query id can be used by Snowflake support or other groups within Snowflake to find information about a query. If you are noticing a change in performance, it is supremely helpful for Snowflake to have a query id for when it was fast and a query id for when it was slow, for example.
It might even be useful to pull information from QUERY_HISTORY and store it in your own table for longer than Snowflake stores it for you.
There are several functions that take the query id as input. GET_QUERY_OPERATOR_STATS allows programatic access to query data similar to the query profile, and it takes a query id for input. You can use the RESULT_SCAN() function along with a query id to read the results of a previous query instead of having to re-execute it. There are benefits and drawbacks to that from a performance perspective.
Summary
While it is a small piece of information, the query id can be powerful. When colaborating with others or with Snowflake, it can be a quick way to make sure everyone is talking about the same thing. It can allow you to gather more information when the situation warrants it.

