How to Make Your Own Snowflake Query Profile

Visual Query Execution Plan

Snowflake just released a useful system table function called GET_QUERY_OPERATOR_STATS, which basically allows you from now on to create your own query profile. Users and administrators asked for this because of the need for more DevOps and automation: instead of visually using the Query Profile from the History tab, we all need to rather watch monitoring raw data.

I will describe here my own little project in Python that generates SVGs in static HTML files with similar Snowflake query execution plans, using the information returned by the new system function.

Snowflake’s Query Profile

Based on a query ID stored in INFORMATION_SCHEMA — and later exposed by QUERY_HISTORY from ACCOUNT_USAGE schema — the visual Query Profile from the History tab was showing way more info on screen than any EXPLAIN query plan or any metadata view.

This is a portion of the complex TPCH_SF1 query below, that I will use in this post:

GET_QUERY_OPERATOR_STATS

With GET_QUERY_OPERATOR_STATS it is now possible to get a table result with all the steps included in the…

--

--

Cristian Scutaru
Snowflake Builders Blog: Data Engineers, App Developers, AI/ML, & Data Science

World-class expert in Snowflake Data Cloud. Former Snowflake "Data Superhero". SnowPro SME (Subject Matter Expert). 5x SnowPro certification exams.