# Query Analyzer

## Overview

Query Analyzer is the **deep-dive analysis view for a single query execution or query pattern**. Use it to understand **why** a query is slow or expensive, pinpoint bottlenecks in the **query plan**, and generate optimization guidance with **Query Agent (beta)**.

### **Why use the Query Analyzer?**

Standard Snowflake history views use "pagination sorting," meaning they only sort the rows currently visible on your screen. **We perform backend sorting on all queries from the last 7 days.** This ensures that when you sort by duration or cost, you are seeing the true top outliers from your entire week's history, not just the current page.

{% hint style="warning" %}
**Prerequisite: Permissions Required** To use the **Analyze** button without internal errors,\
Please make sure you provided the [required permission](https://docs.seemoredata.io/external-docs/fundamentals/getting-set-up/setting-integrations/snowflake/create-snowflake-user-and-privileges#allowlist-the-datamaze-ip-0-15)

{% code overflow="wrap" %}

```sql
GRANT MANAGE WAREHOUSES ON ACCOUNT TO ROLE seemore_user_role;
```

{% endcode %}
{% endhint %}

***

## **Key Capabilities**

### **Global Search & Advanced Filtering**

Locate problematic queries instantly using filters that connect insights, table dependencies, and execution metrics:

* **Performance Metrics:** Filter by **Queuing Time** (e.g., > 100 seconds) or **Execution Time**.
* **Resource Issues:** Filter specifically for **Remote Spillage**, **Local Spillage**, or **Exploding Joins**.
* **Insights:** Filter for queries where we have already detected optimization opportunities.
* **Text Search:** Search for any specific SQL text or Query ID across the entire 7-day history.

### **Deep Dive Analysis**

Clicking into a specific query provides a comprehensive breakdown:

* **Visual Execution Plan:** View the query plan and jump directly to the **most expensive nodes**.
* **Source & Destination Mapping:** Unique to our platform, we map exactly which tables are being read (Source) and, for DML operations, exactly where data is being written (Destination). This includes table size and clustering context.
* **Performance Summary:** An evaluation of time and cost to help determine if the query is performing normally.

### **The "Analyze" Button**

Clicking **Analyze** triggers a deep scan of the execution plan, metadata, and clustering statistics.

* **What it does:** It generates a business logic summary, resource metrics, and specific recommendations.
* **Recommendations:** The system may suggest increasing warehouse size (if heavy spillage is detected) or adding clustering columns to specific tables.

***

## **How to Use**

{% stepper %}
{% step %}
**Look For a Query**

Wherever you can find a query just click on it, Workloads page for example:

<figure><img src="https://3620459840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnSbIoBjUxWTGNWa9gGw7%2Fuploads%2FRKauiuz5eMJEqPeORDZU%2Fimage.png?alt=media&#x26;token=2bf7dd47-3c20-4f2b-a103-3d4b39b36a6d" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Filter & Sort**

Apply filters in the **Query History page** and look for the most problematic queries that should be optimized (e.g., "Has Remote Spillage").

* Sorting may take a moment because we are processing the full 7-day dataset to ensure accuracy.

<figure><img src="https://3620459840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnSbIoBjUxWTGNWa9gGw7%2Fuploads%2FXpFMnbBhZ25eFJHaZ4rq%2Fimage.png?alt=media&#x26;token=42d7dfc5-5779-4b49-89f1-390ea7bbca6e" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Select a Query**

Click on a query to open the details page.
{% endstep %}

{% step %}
**Run Analysis**

Click the Analyze button

<figure><img src="https://3620459840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnSbIoBjUxWTGNWa9gGw7%2Fuploads%2FJwck7pg5gcZNaASrZ5hJ%2Fimage.png?alt=media&#x26;token=75c573f3-bf53-4a98-9438-f4b8d16ca191" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}
**Share Results**

While there is no direct "Share" button (yet), the **Copy Link** function works perfectly if you need to send a specific analysis to a colleague.
{% endstep %}
{% endstepper %}

***

## **Optimizing Your Workflow**

* **Spillage:** If the Analyzer detects significant local or remote spillage, it will recommend resizing the warehouse. Note that this is currently a rule-based recommendation.
* **Clustering:** We identify if source tables lack clustering columns, which can often solve performance bottlenecks.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.seemoredata.io/external-docs/fundamentals/our-features/query-analyzer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
