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?
Snowflake cannot prune on a predicate that contains a subquery, even one that returns a constant. The problem is the predicate, not the data layout, which is already good because of load order. Rewriting the filter with a literal value fixes it. A clustering key won't help, and neither will warehouse size. Selecting fewer columns cuts the columns scanned inside each partition but not the number of partitions read.
“Snowflake does not prune micro-partitions based on a predicate with a subquery, even if the subquery results in a constant.”Source: docs.snowflake.com
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.
SELECT SYSTEM$CLUSTERING_INFORMATION('test2', '(col1, col3)');| Field | Meaning | Poor clustering looks like |
|---|---|---|
| total_partition_count | Micro-partitions in the table (capped at 2 million, with results based on a subset of partitions) | Context for the other numbers |
| total_constant_partition_count | Partitions whose values for the columns have reached a constant state and won't benefit from reclustering | Few or none |
| average_overlaps | Average number of partitions each partition overlaps with | A high number |
| average_depth | Average overlap depth per partition (the same value SYSTEM$CLUSTERING_DEPTH returns) | A high number |
| partition_depth_histogram | Partitions counted by overlap depth: buckets 0 to 16 in steps of 1, then 32, 64, 128 and so on | Most partitions in the high buckets |
| notes | Suggestions, such as a warning about extremely high key cardinality | A warning about the key |
| clustering_errors | Timestamped 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)');SYSTEM$CLUSTERING_INFORMATION returns the full JSON report, including average_overlaps, partition_depth_histogram and clustering_errors. You can run it on any columns, so it also works as a what-if before you choose a key. SYSTEM$CLUSTERING_DEPTH returns only the average depth.
Source: docs.snowflake.comCheckpoint 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?
Correct answer: A — The table is poorly clustered on its current key, so reclustering or picking a different key would reduce the partition overlap.
- A. A high average_depth means many micro-partitions overlap on the clustering column, so queries filtering on order_date scan far more partitions than necessary; reclustering or a different key narrows that overlap.
- B. SYSTEM$CLUSTERING_INFORMATION reports overlap on the existing key rather than whether the key still exists, and a dropped key would surface as a metadata error, not a depth value.
- C. average_depth is a storage-layout metric computed from micro-partition metadata, not a compute metric, so resizing the warehouse running the query has no effect on it.
- D. Table size alone does not justify a high depth value; a 2 TB table with an appropriate clustering key and healthy maintenance can still report a low, well-clustered depth.
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?
Clustering directly on a nanosecond timestamp is a poor choice because it has too many distinct values. An expression that keeps the original order, like TO_DATE(sale_ts), reduces the distinct values and still lets partition min/max ranges prune. A Boolean has too few distinct values and prunes very little. Going past 3–4 columns or expressions tends to add cost faster than benefit.
“Snowflake recommends defining the key as an expression on the column, rather than on the column directly, to reduce the number of distinct values.”Source: docs.snowflake.com
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)
Correct answers: A, B, D — Put the most frequently filtered column, event_date, first in the clustering key so range predicates on it prune the most partitions.; Check the existing natural insert order before adding a key, since data already loaded roughly by event_date may already prune well without one.; Weigh the ongoing reclustering credit cost against the query performance gain, since Automatic Clustering bills separately from warehouse compute.
- A. Correct — leading a clustering key with the column carrying the most selective, frequently used range filter maximizes pruning for the dominant query pattern.
- B. Correct — tables already loaded in an order that matches the query pattern can prune well without an explicit key, so checking current clustering avoids unnecessary reclustering cost.
- C. Incorrect — Snowflake supports only one clustering key made of a small number of expressions; stacking every filtered column dilutes ordering and can worsen overlap instead of improving it.
- D. Correct — Automatic Clustering consumes serverless credits tracked separately from warehouse compute, so the ongoing cost has to be weighed against the pruning benefit before committing to a key.
- E. Incorrect — leading with a low-cardinality column like region groups too few distinct values per partition and typically prunes worse than leading with a high-selectivity range column like a date.
- F. Incorrect — the decision to cluster depends on query patterns and pruning inefficiency, not on a fixed size threshold; some sub-10 TB tables benefit and some multi-TB tables do not.
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?
Correct answer: A — The table receives DML fast enough that reclustering has not yet caught up, or customer_id is a poor fit for the actual filter pattern.
- A. Ongoing reclustering credit consumption combined with persistent overlap usually means either the write rate is outpacing the reclustering work, or the chosen key does not match how the table is actually queried.
- B. SYSTEM$CLUSTERING_INFORMATION is computed against current metadata each time it runs, so it reflects the table's present state rather than a snapshot frozen at creation.
- C. The function and the Snowsight clustering visualization both read from the same underlying micro-partition metadata, so they do not diverge in what they report.
- D. AUTOMATIC_CLUSTERING_HISTORY records clustering-specific credit usage in a dedicated view separate from Search Optimization Service maintenance, so the activity billed there is reclustering work, not SOS.
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.
| Column | Measures | Response |
|---|---|---|
| AVG_RUNNING | Queries actively executing | High with queuing: move work to a separate warehouse or add clusters. Low while queries are slow: resize, then re-run the query |
| AVG_QUEUED_LOAD | Queries waiting because the warehouse was overloaded | Separate warehouse for the queued work, or multi-cluster settings that add clusters |
| AVG_QUEUED_PROVISIONING | Queries waiting while compute was provisioned | Expected in the first few minutes after a warehouse resumes |
| AVG_BLOCKED | Queries blocked by a transaction lock | Find 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?
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.
When running load is low, the warehouse is underused rather than crowded, so the fix to try is more compute per query. High running load with queuing means queries are competing, so the work has to be spread out. A provisioning wait right after a resume is normal. When total load stays below 1 for long periods, the warehouse is oversized and wastes credits.
“If the running query load is low and query performance is slow, you could resize the warehouse to provide more compute resources.”Source: docs.snowflake.com
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?
Clustering depth is for monitoring the health of a large table over time as DML is performed, and the errors array says why automatic clustering could not recluster. Warehouse size and load do not change depth, and only an empty table has a depth of 0.
“particularly over time as DML is performed on the table.”Source: docs.snowflake.com
Sources
(9)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 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.
“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.
“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.
“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.
“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.
“This function returns warehouse activity within the last 14 days.”
↩︎ Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY - 7.
“Latency for the view may be up to 180 minutes (3 hours).”
↩︎ Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY - 8.
“If a warehouse is heavily loaded, concurrent queries might be competing for its compute resources”
↩︎ Telling queuing from blocking in WAREHOUSE_LOAD_HISTORY - 9.
“TABLE_PRUNING_HISTORY | Historical | 6 hours | Data retained for 1 year.”
↩︎ Monitoring pruning and clustering health over time