0
0
Snowflakecloud~3 mins

Why Query history and profiling in Snowflake? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could instantly spot the slowest parts of your database without guessing?

The Scenario

Imagine you run a busy restaurant and want to know which dishes customers order most and how long each takes to prepare.

Without a system, you'd have to remember every order and cooking time yourself.

The Problem

Trying to track every query manually is like writing down every dish order on scraps of paper.

It's slow, easy to lose information, and hard to spot patterns or problems.

The Solution

Query history and profiling tools automatically record every query run and how long it took.

This helps you quickly see which queries are slow or used most, just like a digital kitchen logbook.

Before vs After
Before
SELECT * FROM queries WHERE time > 'yesterday'; -- manually check logs
After
SELECT query_text, total_elapsed_time FROM table(information_schema.query_history()) WHERE start_time > DATEADD(day, -1, CURRENT_TIMESTAMP());
What It Enables

It lets you easily find slow queries and optimize your database performance like a chef improving kitchen speed.

Real Life Example

A data analyst notices a report runs slowly every morning.

Using query profiling, they find a specific query causing delays and fix it, speeding up the report.

Key Takeaways

Manual tracking of queries is slow and error-prone.

Query history automatically logs all queries and their details.

This helps find and fix slow or costly queries quickly.