The warehouse mental model — micro-partitions, clustering, scan vs compute
Build the map before tuning anything: a table is a set of micro-partitions, every query is described by bytes scanned, partitions scanned ratio, and queue time, a clustering key decides how much gets pruned, and a slow query is either a scan problem or a compute problem — never both at once.
At a glance
| When | Before tuning anything on a warehouse; Onboarding onto a team that shares one warehouse |
|---|---|
| Where | dbt |
| Why | Every warehousing decision later in the series is a choice about partitions, clustering, or compute — and this is the map of all three. |
Learning objectives
- Name the three numbers that describe a warehouse query — bytes scanned, partitions scanned ratio, queue time
- Explain why a table is a set of micro-partitions and what a clustering key prunes
- Separate a scan problem from a compute problem before touching any knob
What you need
- A warehouse to reason about — Snowflake, BigQuery, or Redshift
- Install: npx de-agent-platform add warehouse-clustering-advisor
- One slow query and one fast query from your own history to compare
Steps
- The advisor's scope is the mental model's table of contents: clustering keys, warehouse sizing, result caching, and the difference between a scan problem and a compute problem. (from skill-warehouse-clustering-advisor )
- Describe any warehouse query with the three numbers on the runbook's monitoring list — bytes scanned, partitions scanned ratio, queue time. (from runbook-warehouse-query-slow )
- A table is physically a set of micro-partitions; the runbook lists data volume growth crossing a micro-partition threshold as a cause — a query can go slow with no change at all. (from runbook-warehouse-query-slow )
- Diagnose first: a query that scans far more partitions than it needs is a clustering/partition problem; a scan that is optimal but still waits is a warehouse sizing or concurrency problem. (from skill-warehouse-clustering-advisor )
- The clustering key is picked from workload shape — the column that appears in the WHERE clause of the most expensive queries, with reasonable cardinality, most selective first. (from skill-warehouse-clustering-advisor )
- Compute is elastic and separate from storage — if queue time is far above execution time for short queries, scale out (more clusters), not up (bigger warehouse). (from skill-warehouse-clustering-advisor )
- Under the engine sits the logical layer the lesson arc builds — the star schema that stops analysts re-deriving the same joins and disagreeing on metric definitions. (from pattern-dimensional-model )
Check yourself
- You can read a query's bytes scanned, partitions scanned ratio, and queue time and say which side is sick.
- Asked why a query got slow when nothing changed, you answer micro-partition thresholds before blaming code.
- You can name the clustering key you would pick for your most expensive query and why.
Worked example
The three numbers for any query, from query history — from runbook-warehouse-query-slow
-- Snowflake
SELECT query_id, partitions_scanned, partitions_total, bytes_scanned
FROM table(information_schema.query_history_by_session())
ORDER BY start_time DESC LIMIT 10;
Install the clustering advisor skill — from skill-warehouse-clustering-advisor
npx de-agent-platform add warehouse-clustering-advisor
Sourced from
Security scan
Last sweep 2026-10-24: 0 finding(s), 0 marked as examples.
Common gotchas
- Bytes scanned and queue time are different diseases — fix the predicate vs add clusters; sizing up a scan-bound query buys nothing.
- Clustering on a low-selectivity key stops pruning entirely.
- Data volume growth silently crosses micro-partition thresholds — a query can go slow with no change at all.
Production considerations
- Alert on the partitions_scanned/partitions_total ratio from day one.
- Scale out for queue time on short queries; scale up never fixes a scan-bound query.
Diagram
warehouse mental model
|
|- table = micro-partitions --> volume growth crosses thresholds silently
|
|- scan side --> bytes + partitions scanned --> clustering key / predicate
|
|- compute side --> queue time --> scale out (more clusters), not up
|
|- logical layer --> star schema under the engine
Registry stats
| Verification | community · Oct 23, 2026 |
|---|---|
| Completeness | 81 |
| Trust multiplier | ×1.25 |
| Composite | 34.15 · adequate |
| Freshness | 1 days since last source check |
| Difficulty | beginner |
| Version | 0.1.0 |
| License | CC-BY-4.0 |
| Security flags | none |
Did this solve your problem?
The warehouse mental model — micro-partitions, clustering, scan vs compute