Query History and Profiling in Snowflake
📖 Scenario: You are a data analyst working with Snowflake cloud data warehouse. Your manager wants you to track recent queries run on the system and profile their execution times to find slow queries.
🎯 Goal: Build a set of SQL queries to retrieve query history and profile query execution times in Snowflake.
📋 What You'll Learn
Use the
SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY view to get recent queriesFilter queries executed in the last 7 days
Select query id, user name, query text, start time, end time, and execution time
Calculate execution time in seconds
Order results by execution time descending
💡 Why This Matters
🌍 Real World
Tracking query performance helps optimize data warehouse usage and reduce costs by identifying slow or expensive queries.
💼 Career
Data analysts and cloud engineers often profile query history to troubleshoot performance and improve data workflows.
Progress0 / 4 steps