CertSafari
    Snowflake SnowPro Advanced: Architect (ARA-C01)· Lessons

    Domain 4 · Lesson 13/13

    Troubleshooting slow queries with pruning, clustering information and warehouse load

    Troubleshoot performance issues with existing architectures.

    17 min read
    10% of exam
    9 sources
    Published 20 Oct 2026
    Docs as of 18 Oct 2026

    What you will be able to do

    • Explain how micro-partition min/max metadata lets a query skip data, and recognise filters that prevent pruning
    • Read SYSTEM$CLUSTERING_INFORMATION output, including average_depth, average_overlaps and the depth histogram, to judge how well a table is clustered
    • Decide from clustering information whether a clustering key, a different key or a query rewrite is the right fix for a slow table
    • Use the running, queued, provisioning and blocked load in WAREHOUSE_LOAD_HISTORY to choose between resizing, adding capacity or fixing locks
    • Monitor pruning and clustering health over time, choosing the signals and ACCOUNT_USAGE views that show a table drifting before users complain

    Key concept

    Micro-partition pruning — Snowflake records the value range of every column in every micro-partition, and at query time it skips any partition whose range cannot match the filter. How much data a query reads depends on how much the partition ranges overlap for the filtered columns.

    1.How micro-partition metadata lets a query skip data

    Most slow queries on a large Snowflake table are slow because they read more data than they need. Every table is split automatically into micro-partitions holding 50 MB to 500 MB of uncompressed data. For each one, Snowflake records the range of values in every column, the number of distinct values and other properties. At query time the filter is checked against those min/max ranges, and a partition whose range cannot hold a matching value is never opened. Storage is columnar, so inside the partitions that remain, Snowflake scans only the columns the query references.

    Ideal pruning tracks selectivity. A filter that covers 10% of a column's value range should ideally scan about 10% of the micro-partitions. A query for one hour, against a year of evenly spread hourly data, would ideally scan 1/8760th of them. When troubleshooting, use that ratio as the yardstick: the further the share of partitions scanned rises above the share of data actually selected, the worse pruning is working.

    Pruning fails for two different reasons, and each needs a different fix. The first is the predicate. Not every expression can be used to prune, and Snowflake does not prune on a predicate that contains a subquery, even when the subquery returns a constant. A filter such as WHERE order_date = (SELECT MAX(order_date) FROM calendar) therefore can't skip partitions, while the same filter written with a literal date can. The second reason is data layout. If matching values are spread across partitions whose ranges all overlap, every range might hold a match, so none can be skipped. Rewriting the query fixes the first problem. Only changing how the data is clustered fixes the second.

    Layout starts with load order. Micro-partitions follow the order in which rows are inserted or loaded, so a table loaded day by day is already well clustered on its date column without any setting.

    Checkpoint 1 of 8· Check yourself

    An events table is loaded day by day, so its event_date column already follows load order. A report filters with WHERE event_date >= (SELECT start_date FROM fiscal_periods WHERE period = 'current'), and the subquery returns a single date. The query profile shows it scans almost every micro-partition, even though it selects only a few days of data. What is the right fix?

    Sources1

    2.Reading SYSTEM$CLUSTERING_INFORMATION output

    Clustering metadata measures the layout problem. For every table, Snowflake tracks the total number of micro-partitions, how many of them overlap in value range for a given set of columns, and how deep that overlap goes. Clustering depth is the average depth of the overlapping partitions. For a populated table it is 1 or greater (an empty table has 0), and a smaller depth means better clustering on those columns.

    SYSTEM$CLUSTERING_INFORMATION returns all of this as a JSON string. Pass the table name and, in parentheses, the columns or expressions to measure. The column list is required on a table without a clustering key. On a table with a key it is optional, and the defined key is used if you leave it out. You can name any columns, so the function also works as a what-if: measure a candidate column before you cluster on it. SYSTEM$CLUSTERING_DEPTH returns only the average depth.

    Clustering information for table test2 measured on two columnssql
    SELECT SYSTEM$CLUSTERING_INFORMATION('test2', '(col1, col3)');
    Fields in the SYSTEM$CLUSTERING_INFORMATION result and what a poorly clustered table shows
    FieldMeaningPoor clustering looks like
    total_partition_countMicro-partitions in the table (capped at 2 million, with results based on a subset of partitions)Context for the other numbers
    total_constant_partition_countPartitions whose values for the columns have reached a constant state and won't benefit from reclusteringFew or none
    average_overlapsAverage number of partitions each partition overlaps withA high number
    average_depthAverage overlap depth per partition (the same value SYSTEM$CLUSTERING_DEPTH returns)A high number
    partition_depth_histogramPartitions counted by overlap depth: buckets 0 to 16 in steps of 1, then 32, 64, 128 and so onMost partitions in the high buckets
    notesSuggestions, such as a warning about extremely high key cardinalityA warning about the key
    clustering_errorsTimestamped reasons why automatic clustering couldn't recluster (10 most recent by default)Errors such as the clustering service being disabled

    That output is Snowflake's own example for test2 on (col1, col3), and its verdict is that the table is not well clustered. The reasons: zero constant partitions out of 1,156, an average_overlaps of 117.5, a high average depth, and most partitions with an overlap depth between 64 and 128. The histogram buckets increase by one up to 16 and then double, so a mass of partitions in the high buckets is the sign of heavy overlap. A healthy table has most of its partitions in the low buckets. The same output also listed a clustering error showing that the clustering service had been disabled. To get more or fewer than the default 10 errors, pass a number as the second argument instead of a column list.

    Two cautions apply. First, these numbers come from table metadata. The size of the warehouse that runs the function has no effect on them, and no table size makes a high depth expected. Second, depth is not a precise verdict, because query performance is the final test. A table whose queries perform as expected is likely well clustered, and one whose queries slow down over time likely is not. On tables that use Optima Clustering, total_constant_partition_count and partition_depth_histogram are not returned.

    Checkpoint 2 of 8· Fill the gap

    Table test2 has no clustering key. Before you define one, you want the full JSON report for col1 and col3 together: overlaps, depth histogram and any clustering errors. Which function completes the call?

    SELECT  ? ('test2', '(col1, col3)');

    Checkpoint 3 of 8· Exam question

    A data engineer runs SYSTEM$CLUSTERING_INFORMATION against a 2 TB sales fact table clustered on order_date and sees average_depth of 46 with a right-skewed partition_depth_histogram. What should the engineer conclude?

    Sources21

    3.Deciding whether a clustering key is the fix

    A clustering key names the columns or expressions Snowflake keeps co-located, and Automatic Clustering maintains it. The mechanics are in Natural clustering, clustering keys and automatic clustering. The troubleshooting question here is narrower: given a slow table and its clustering information, is a key the right optimization, or is the problem somewhere else?

    Two signs point toward a key: queries that run slower than expected or have degraded over time, and a large clustering depth. Before acting, check that the table and its workload fit. Clustering pays off when all of these hold:

    • The table has a large number of micro-partitions, typically multiple terabytes of data. This is a guideline, not a hard size cut-off.
    • The queries are selective, reading a small share of rows, or they sort the data, for example with ORDER BY.
    • A high share of the queries filter or sort on the same few columns.

    Choose the columns from the workload. Put first the column used most in selective filters, such as the date column on a fact table that is queried by date range. Add join columns or a second filter dimension only if there is room, and stop at three or four columns or expressions, because beyond that costs grow faster than benefits. Aim for middling cardinality. A Boolean such as IS_NEW_CUSTOMER prunes very little, and a nanosecond timestamp has too many distinct values to group well. For a high-cardinality column, cluster on an expression that reduces the distinct values while keeping the original order, so that partition min/max ranges still prune.

    Check the natural order first. Data loaded in roughly chronological order is already partitioned that way, so measure the current layout on the candidate columns with SYSTEM$CLUSTERING_INFORMATION before paying for a key. Also run a representative set of queries first to set a performance baseline.

    Cost is the counterweight. Reclustering is serverless compute that consumes its own credits. It is recorded in ACCOUNT_USAGE.AUTOMATIC_CLUSTERING_HISTORY, and an account-level resource monitor does not control it. The more often a table is queried, the more a key pays back. The more often the table changes, the more it costs to keep clustered. If heavy DML can't be avoided, group it into large, infrequent batches.

    Sometimes a key exists and depth stays high anyway. Defining a key does not reorder rows immediately, because Snowflake reclusters only when the table will benefit. Suppose that a week after adding a key on customer_id, average_overlaps is still high while AUTOMATIC_CLUSTERING_HISTORY shows credits being spent. Two explanations fit. Either DML is arriving faster than reclustering can catch up, or customer_id doesn't match what the slow queries actually filter on. Compare the key with those filter columns and read the notes field. If the real cause is a subquery predicate, no key will help, and the predicate has to be rewritten.

    Checkpoint 4 of 8· Check yourself

    A multi-terabyte sales fact table has slowed down over time. Most queries filter on narrow ranges of sale_ts, which is a nanosecond timestamp, and many also filter on region. You decide a clustering key is justified. Which key best follows Snowflake's guidance?

    Checkpoint 5 of 8· Exam question

    A team is choosing a clustering key for a 5 TB events table that is almost always filtered by event_date and occasionally by region, and both columns are written in roughly chronological order. Which considerations should guide the decision? (Select all that apply)(Select 3)

    0 of 3 selected

    Checkpoint 6 of 8· Exam question

    After adding a clustering key on customer_id, an analyst reruns SYSTEM$CLUSTERING_INFORMATION a week later and still sees a high average_overlaps value, even though Automatic Clustering shows active credit consumption in ACCOUNT_USAGE.AUTOMATIC_CLUSTERING_HISTORY. What is the most likely explanation?

    Sources34

    4.Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY

    If pruning is fine and a query is still slow, the warehouse may be the bottleneck. An overloaded warehouse queues queries, and multi-cluster warehouses add clusters to absorb concurrency, as explained in Warehouse queuing and multi-cluster warehouses (scale out). On an existing warehouse, WAREHOUSE_LOAD_HISTORY shows which kind of waiting is happening.

    Each column holds a query load: the total execution time of all queries in one state during an interval, divided by the length of the interval. For example, four queries that ran a combined 276 seconds in a 300-second interval give a load of 0.92. The view splits load into four states, and each one points to a different fix.

    WAREHOUSE_LOAD_HISTORY columns, what each signals, and the response
    ColumnMeasuresResponse
    AVG_RUNNINGQueries actively executingHigh with queuing: move work to a separate warehouse or add clusters. Low while queries are slow: resize, then re-run the query
    AVG_QUEUED_LOADQueries waiting because the warehouse was overloadedSeparate warehouse for the queued work, or multi-cluster settings that add clusters
    AVG_QUEUED_PROVISIONINGQueries waiting while compute was provisionedExpected in the first few minutes after a warehouse resumes
    AVG_BLOCKEDQueries blocked by a transaction lockFind the conflicting transactions (LOCK_WAIT_HISTORY) rather than changing warehouse size

    Read running and queued load together. High running load with queuing means queries are competing for the same compute, and moving the queued work to its own warehouse or adding clusters spreads it out. Low running load with slow queries means the warehouse is underused, not crowded. The test then is a larger size, with the query restarted once the new resources are fully provisioned. A larger warehouse helps most with large, complex queries, and on a heavily loaded warehouse it does less than expected because concurrent queries still compete. The opposite problem also shows up here. Long stretches where the warehouse is running and consuming credits but total load is below 1 mean it is oversized, so reduce its size or lower MIN_CLUSTER_COUNT.

    The same data comes from two places. The INFORMATION_SCHEMA table function WAREHOUSE_LOAD_HISTORY covers only the last 14 days. It uses 5-second intervals for ranges under 8 hours and 5-minute intervals otherwise. The ACCOUNT_USAGE view of the same name uses 5-minute intervals and can lag by up to 180 minutes, which suits trend questions such as this one: on which days in the last month did each warehouse queue?

    Daily running and queued load over the last month, showing only days with queuingsql
    SELECT TO_DATE(start_time) AS date,
      warehouse_name,
      SUM(avg_running) AS sum_running,
      SUM(avg_queued_load) AS sum_queued
    FROM snowflake.account_usage.warehouse_load_history
    WHERE TO_DATE(start_time) >= DATEADD(month,-1,CURRENT_TIMESTAMP())
    GROUP BY 1,2
    HAVING SUM(avg_queued_load) >0;

    Checkpoint 7 of 8· Match them up

    Match each pattern in WAREHOUSE_LOAD_HISTORY to the response it calls for.

    Tap a term, then the definition that fits it.

    Sources5678

    5.Monitoring pruning and clustering health over time

    A table that prunes well today can stop pruning well after months of inserts, updates and deletes, and nothing announces the change. Monitoring exists to catch that drift before a dashboard times out. A single reading of clustering information is a snapshot; its value comes from comparing readings taken at intervals, which is exactly what clustering depth is meant for: watching the clustering health of a large table over time as DML is performed on it.

    Three signals deserve a place in that routine. Average depth and average overlaps rising from one reading to the next show the layout degrading. The clustering_errors array explains why automatic clustering could not recluster, so a growing list of errors turns a mystery into a cause. And query performance remains the final arbiter: depth is not an absolute measure, so a table whose queries have slowed is a candidate for clustering even when the depth looks moderate.

    For history that outlasts a single session, ACCOUNT_USAGE carries TABLE_PRUNING_HISTORY, TABLE_QUERY_PRUNING_HISTORY and COLUMN_QUERY_PRUNING_HISTORY, with latency of four to six hours and a year of retention, alongside AUTOMATIC_CLUSTERING_HISTORY for the credits spent keeping tables clustered. That latency makes them trend tools, not incident tools. When a drift threshold matters enough to page someone, a scheduled alert can evaluate a query over these views and send the notification.

    Checkpoint 8 of 8· Check yourself

    Six months ago a large table had a low average_depth. Heavy DML has run since, and its queries have slowly become slower. Which monitoring step best shows whether layout drift is the cause?

    Sources129

    Sources

    (9)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Snowflake does not prune micro-partitions based on a predicate with a subquery, even if the subquery results in a constant.”
      ↩︎ How micro-partition metadata lets a query skip data
      “should ideally only scan 10% of the micro-partitions”
      ↩︎ How micro-partition metadata lets a query skip data
      “Tables are transparently partitioned using the ordering of the data as it is inserted/loaded.”
      ↩︎ How micro-partition metadata lets a query skip data
      “Ultimately, query performance is the best indicator of how well-clustered a table is”
      ↩︎ Reading SYSTEM$CLUSTERING_INFORMATION output
      “particularly over time as DML is performed on the table.”
      ↩︎ Monitoring pruning and clustering health over time
      “First, prune micro-partitions that are not needed for the query.”
      ↩︎ Key concept
      “The smaller the average depth, the better clustered the table is with regards to the specified columns.”
      ↩︎ Exam trap 1
    2. 2.
      “A histogram depicting the distribution of overlap depth for each micro-partition in the table.”
      ↩︎ Reading SYSTEM$CLUSTERING_INFORMATION output
      “you can use this to help you decide what clustering to use in the future.”
      ↩︎ Reading SYSTEM$CLUSTERING_INFORMATION output
      “The error describes why automatic clustering was not able to recluster data.”
      ↩︎ Monitoring pruning and clustering health over time
      “Average overlap depth of each micro-partition in the table. A high number indicates the table is not well-clustered.”
      ↩︎ Prediction
    3. 3.
      “Typically, this means that the table contains multiple terabytes (TB) of data.”
      ↩︎ Deciding whether a clustering key is the fix
      “Cluster columns that are most actively used in selective filters.”
      ↩︎ Deciding whether a clustering key is the fix
      “the more frequently a table changes, the more expensive it will be to keep it clustered.”
      ↩︎ Deciding whether a clustering key is the fix
      “After you define a clustering key for a table, the rows are not necessarily updated immediately.”
      ↩︎ Deciding whether a clustering key is the fix
      “For most tables, Snowflake recommends a maximum of 3 or 4 columns (or expressions) per key.”
      ↩︎ Exam trap 2
      “Snowflake recommends defining the key as an expression on the column, rather than on the column directly, to reduce the number of distinct values.”
      ↩︎ Checkpoint
    4. 4.
      “does not control credit usage by the Snowflake-provided compute resources for serverless features (for example, Snowpipe, automatic reclustering”
      ↩︎ Deciding whether a clustering key is the fix
    5. 5.
      “If the running query load is low and query performance is slow, you could resize the warehouse to provide more compute resources.”
      ↩︎ Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY
      “If the running query load is high or there’s queuing, consider starting a separate warehouse and moving queued queries to that warehouse.”
      ↩︎ Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY
      “Queries that were blocked during the interval due to a transaction lock.”
      ↩︎ Prediction
    6. 8.
      “If a warehouse is heavily loaded, concurrent queries might be competing for its compute resources”
      ↩︎ Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY
    7. 9.
      “TABLE_PRUNING_HISTORY | Historical | 6 hours | Data retained for 1 year.”
      ↩︎ Monitoring pruning and clustering health over time

    Continue to part 2 of 2

    Monitoring Snowflake with ACCOUNT_USAGE, resource monitors, alerts and event tables

    Spotted a mistake, or was something unclear? Tell us.