Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Snowflake · SnowPro Core

Query Profile and Query Performance

SnowPro Core · Lesson 20 of 27 · 2:31:46

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the SnowPro Core Certification exam (COF-C03). In this lesson: the Query Profile, spilling, poor pruning, exploding joins, queuing, and query history and attribution. Follows Foxglove Apparel, a fictional online clothing retailer. Includes three original practice questions.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

From two minutes to forty

Foxglove's weekly margin report used to take two minutes, and now it takes forty. The analyst blames Snowflake, the engineer blames the warehouse size, and nobody has looked at the query itself. The Query Profile and the account usage views show exactly where the time goes.

The Query Profile

The Query Profile shows the execution plan of a query, as a tree of operator nodes, such as table scans, joins, and aggregates. Each node shows its share of the execution time, and the most expensive nodes are listed, so you start where the time goes. Statistics show the bytes scanned, the percentage scanned from the cache, and the partitions scanned compared with the partitions in total. Query insights add ready-made advice about conditions that affect performance, in Snowsight and in the QUERY_INSIGHTS view.

Spilling and pruning

When intermediate results do not fit in memory, the query spills to local disk, and if that is not enough, to remote storage, which is far slower. The fixes are a larger warehouse, which brings more memory and local disk, or processing the data in smaller batches. Poor pruning shows up as partitions scanned close to partitions total, in a table scan. It means that the filter does not match the storage order, which a better filter, or a clustering key, can fix.

Exploding joins and other mistakes

An exploding join happens when a join has no join condition, which is a Cartesian product, or a condition that matches many rows on each side. In the profile, the join operator produces far more rows than it receives, often by orders of magnitude, and it takes much of the time. Another common mistake is UNION where UNION ALL would do: UNION also removes duplicates, which adds an aggregate operator on top. And selecting only the columns you need reduces the bytes scanned, since storage is columnar.

Queuing

Queuing happens when a warehouse is too busy to start new queries, so they wait for resources. The warehouse activity chart in Snowsight shows the queued load, and QUERY_HISTORY shows how long each query was queued. For a single warehouse, spread the queries across additional warehouses, or turn it into a multi-cluster warehouse. And if it is already multi-cluster, raise its maximum number of clusters.

Query history and attribution

QUERY_HISTORY, in ACCOUNT_USAGE, keeps a year of queries, with their duration, bytes scanned, spilling, and queued time. QUERY_ATTRIBUTION_HISTORY assigns warehouse credits to each query, and its compute credits exclude the time the warehouse sat idle. Both views let you group runs of the same query, with different values, by their parameterized hash, and by query tag. The attribution view can lag by up to eight hours, so it suits analysis rather than live monitoring.

Grouping similar workloads

Grouping similar workloads on the same warehouse makes tuning easier, since a change benefits every query that runs there. If a warehouse mixes very different queries, the cost of an optimization may be wasted on queries that do not benefit. So separate loading, reporting, and data science onto their own warehouses, each sized and scaled for its job. This also makes costs easier to attribute, team by team.

Recap

Let's recap. The Query Profile shows operator nodes, the most expensive nodes, and statistics such as partitions scanned and bytes spilled. Spilling to remote storage calls for a larger warehouse, or smaller batches, and poor pruning calls for better filters or clustering. Exploding joins and needless UNION are common query mistakes. Queuing calls for more warehouses, or more clusters. And QUERY_HISTORY and QUERY_ATTRIBUTION_HISTORY show durations and credits per query, while similar workloads belong on the same warehouse.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. In the Query Profile of Foxglove’s slow report, a sort operator shows many gigabytes spilled to remote storage. What is the most direct fix?

    • Add clusters to a multi-cluster warehouse
    • Rely on the query result cache
    • Run the query on a larger warehouse
    • Add search optimization to the table
    Show the answer

    Run the query on a larger warehouse

    A larger warehouse brings more memory and local disk, so the operation spills less, or not at all. “Add clusters to a multi-cluster warehouse” adds clusters for more concurrent queries, but each query still runs on a cluster of the same size. “Rely on the query result cache” only helps when the exact same query runs again. And “Add search optimization to the table” speeds up selective lookups, not a large sort.

  2. Foxglove’s report joins orders to shipments, and the Query Profile shows the join producing two hundred times more rows than it receives. What is the most likely cause?

    • A missing or partial join condition
    • Remote spilling on a small warehouse
    • A disabled query result cache
    • Queuing on the warehouse
    Show the answer

    A missing or partial join condition

    A missing or partial join condition matches many rows on each side, so the join explodes. “Remote spilling on a small warehouse” can follow from the extra rows, but it does not create them. “A disabled query result cache” has no effect on how many rows a join produces. And “Queuing on the warehouse” delays the start of a query, without changing its plan.

  3. Finance asks how many credits Foxglove’s nightly margin query consumed last month, without counting the time its warehouse sat idle. Where should the analyst look?

    • WAREHOUSE_METERING_HISTORY
    • The Query Profile of one run
    • METERING_DAILY_HISTORY
    • QUERY_ATTRIBUTION_HISTORY
    Show the answer

    QUERY_ATTRIBUTION_HISTORY

    QUERY_ATTRIBUTION_HISTORY assigns credits to each query, without the warehouse's idle time. “WAREHOUSE_METERING_HISTORY” gives credits per warehouse, hour by hour, idle time included. “The Query Profile of one run” shows the plan of a single run, not credits. And “METERING_DAILY_HISTORY” gives daily totals for the whole account.