> For the complete documentation index, see [llms.txt](https://docs.seemoredata.io/external-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.seemoredata.io/external-docs/fundamentals/our-features/query-optimization.md).

# Query Optimization

Find the recurring queries that cost the most and can be optimized, assign them to an owner, and track them until they are fixed.

## Overview

**Query Optimization** lists your **recurring queries** that can be optimized, ranked by what they cost. Because these queries run again and again, fixing one cuts its cost on every future run.

A query is listed when it ran **at least twice** in the selected time range and could run cheaper or faster — for example, because of an exploding join or a table scan with no filter.

Use the page to:

* Spot the queries worth fixing first, with their cost over the period and an estimated yearly cost.
* Assign each query to a user or team, set its status, and leave a comment, so the whole team can see who is working on what.
* Ask the [Seemore Assistant](/external-docs/fundamentals/our-features/seemore-assistant.md) how to rewrite a query so it costs less.

Open it from **Query Optimization** in the main navigation.

<figure><img src="https://3620459840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnSbIoBjUxWTGNWa9gGw7%2Fuploads%2Fgit-blob-98cbc5936b31dafb196f24e41030e7be4a7e7ff2%2Fquery-optimization-page.png?alt=media" alt="The Query Optimization page with summary cards and the list of recurring queries"><figcaption><p>The Query Optimization page</p></figcaption></figure>

{% hint style="info" %}
**Required role to configure:** [Editor](/external-docs/fundamentals/settings/user-roles.md) or higher.

Users with lower roles can view this feature and analyze queries but cannot change a query's status or comment.
{% endhint %}

***

## Summary cards

The cards at the top count the queries in each category. Click a card to show only its queries; click it again to clear it. The page opens on **Top opportunity**.

| Card                | Shows recurring queries that…                                                                          |
| ------------------- | ------------------------------------------------------------------------------------------------------ |
| **Top opportunity** | Cost **$1 or more per run** on average. Hover the info icon to see the threshold.                      |
| **With insights**   | Have any optimization insight. This is the full list.                                                  |
| **Failed**          | Failed at least once. Selecting this card adds a **Success rate** column.                              |
| **Retried**         | Were retried by Snowflake at least once.                                                               |
| **Remote spillage** | Spilled data to remote storage at least once, usually a sign the warehouse is too small for the query. |
| **Blocking**        | Spent time blocked by another transaction's lock.                                                      |

***

## The queries table

Each row is one recurring query. By default the table is sorted by **Cost**, highest first.

| Column                   | Description                                                                                                                                              |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Account**              | The Snowflake account the query runs in.                                                                                                                 |
| **Compute unit**         | The warehouse that ran the query.                                                                                                                        |
| **Query**                | The query text and the ID of its latest run. Click it to open the query in [Query Analyzer](/external-docs/fundamentals/our-features/query-analyzer.md). |
| **Insights**             | The number of optimization insights. Hover to see which ones.                                                                                            |
| **User**                 | The Snowflake user that ran the query.                                                                                                                   |
| **Avg daily executions** | How many times a day the query runs on average.                                                                                                          |
| **Success rate**         | The share of runs that succeeded. Shown only on the **Failed** card.                                                                                     |
| **Avg duration**         | How long a run takes on average, from start to finish, including time spent compiling, queued, or blocked.                                               |
| **Cost**                 | What the query cost over the time range, with an estimated yearly cost below it. Use the **Cost / Credits** toggle above the table to switch units.      |
| **Assigned to**          | The user or team responsible for the query.                                                                                                              |
| **Status**               | Where the fix stands: **Open**, **In progress**, **Done**, or **Ignored**.                                                                               |
| **Comment**              | A free-text note for the team.                                                                                                                           |

You can sort by **Avg daily executions**, **Success rate**, and **Cost**, show or hide columns with the **+** button, and use **Search by query ID** to find a specific run's query.

***

## How to work through your queries

{% stepper %}
{% step %}

#### Narrow the list

Use the controls at the top of the page:

* **Status** and **Assigned to** — show queries by triage state or owner. By default the page shows **Open** and **In progress** queries, so finished and ignored work stays out of the way.
* **Time range** — **Yesterday**, **Last 3 days**, **Last 7 days** (default), or a custom range of up to 7 days.
* **Filter** — narrow by **Account**, **Compute unit**, **User**, or **Insights** type.

<figure><img src="https://3620459840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnSbIoBjUxWTGNWa9gGw7%2Fuploads%2Fgit-blob-6b2fd0e8b75b49b33c949df73803e4618e213633%2Fquery-optimization-filters.png?alt=media" alt="The filter panel with Account, Compute unit, User and Insights filters"><figcaption><p>Filters and summary cards</p></figcaption></figure>
{% endstep %}

{% step %}

#### Pick a query and analyze it

Start with **Top opportunity** — the queries that cost the most per run. Hover a row and click **Analyze** to open the [Seemore Assistant](/external-docs/fundamentals/our-features/seemore-assistant.md) with the query: it explains the insights, what the query plan shows, and how to rewrite the query so it costs less.

{% hint style="info" %}
**Analyze** appears only when the Seemore Assistant is enabled for your account.
{% endhint %}

For a full breakdown of a single run, click the query text to open it in [Query Analyzer](/external-docs/fundamentals/our-features/query-analyzer.md).
{% endstep %}

{% step %}

#### Assign, track, and comment

{% hint style="info" %}
**Required role to assign:** [Admin](/external-docs/fundamentals/settings/user-roles.md) or higher.

Users with lower roles see who a query is assigned to but cannot change it.
{% endhint %}

Use the **Assigned to**, **Status**, and **Comment** cells to triage a query right in the table:

* **Assigned to** — pick a user or a team. The new assignee gets an email notification.
* **Status** — move the query from **Open** to **In progress**, then to **Done** once fixed, or **Ignored** if it is not worth fixing.
* **Comment** — leave context for the team, such as the planned fix.

<figure><img src="https://3620459840-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FnSbIoBjUxWTGNWa9gGw7%2Fuploads%2Fgit-blob-a1d8d85882bd43640a26e20902fd03b6bbd8058b%2Fquery-optimization-status.png?alt=media" alt="Changing a query&#x27;s status from the Status column"><figcaption><p>Setting a query's status</p></figcaption></figure>
{% endstep %}

{% step %}

#### Save your view

Save the filters, status, and assignee selection you use most as a [view](/external-docs/fundamentals/our-features/observability/views.md) from the **View** selector or the filter panel's **Create View** button — for example, "My open queries" or a view per team.
{% endstep %}
{% endstepper %}

***

## On the dashboard

The **Queries that can be optimized** list on the dashboard shows your costliest open recurring queries from the last 7 days. Click a query, or **View all**, to jump to it on the Query Optimization page.
