Sub topic 3
Picking a warehouse size
This chapter assumes you can write basic SQL, know what a SQL warehouse is, and have seen the three warehouse types (serverless, pro, classic). It covers what "size" means, how to choose one, and the mistakes that lead to wasted money or slow queries.
What size controls
A warehouse size is a T-shirt label, such as 2X-Small, Small, or Large. Each label maps to a cluster of a fixed amount of compute. A warehouse is made of one or more identical clusters, and the size sets how big each cluster is.
Size changes how much work one query can spread across at once. A larger cluster has more workers, so a single heavy query can run in parallel on more data. Size does not change how many users the warehouse can serve at the same time. That is the job of the number of clusters, which the next chapter covers.
Sizes roughly double in compute at each step. Cost per hour roughly doubles as well, measured in DBUs (Databricks Units, the billing unit for compute).
| Size | Relative compute | Relative hourly cost |
|---|---|---|
| 2X-Small | 1x | 1x |
| X-Small | 2x | 2x |
| Small | 4x | 4x |
| Medium | 8x | 8x |
| Large | 16x | 16x |
Larger sizes (X-Large up to 4X-Large) continue the pattern. The exact DBU rates differ by warehouse type and change over time, so check the pricing page for current numbers. The doubling pattern is what you use to reason about trade-offs.
Why bigger is not always more expensive per query
You pay for the time a warehouse is running, multiplied by its hourly rate. So the cost of one query is roughly its runtime times the rate.
If a query scales well, doubling the size halves the runtime. The cost stays about the same, and you get the answer sooner.
Suppose a query takes 8 minutes on a Small warehouse (4x rate):
- Small: 8 minutes at 4x is 32 units.
- Medium: about 4 minutes at 8x is 32 units.
- Large: about 2 minutes at 16x is 32 units.
The cost is the same, but the Large result arrives four times faster. This holds only while the query keeps scaling. Past a certain point, extra workers sit idle and you pay more for little gain.
What scales well and what does not
Queries that benefit from a larger size:
- Large scans and aggregations over many files.
- Big joins and wide shuffles, where data moves between workers.
- Queries that spill to disk because memory is short. More memory per cluster can remove the spill.
Queries that gain little:
- Short, selective lookups that read a small amount of data.
- Queries dominated by a single slow step, such as one skewed partition where one worker does most of the work.
- Queries waiting on cold storage or on other queries rather than on compute.
If you are unsure which group a query is in, run it and read the query profile (covered later in this tutorial). Look for time spent in scans and shuffles, and for spill to disk. Those point to a size problem. A profile dominated by a single task points to skew, which a bigger size will not fix.
A practical way to choose
Do not guess from the table size alone. Measure.
- Start with a modest size, such as Small, for a new workload.
- Run a representative query and note the runtime in query history.
- Move up one size and run the same query again.
- Compare the runtimes. If the time dropped by close to half, keep going. If it dropped by much less, stay at the smaller size.
- Repeat until the improvement flattens, then choose the last size that still helped.
When you test, repeat each run more than once. The first run may be slower because data has not been cached yet. Caching is covered in a later chapter, and you should compare warm runs with warm runs.
You can use a query like this one as a benchmark. It scans a whole table and aggregates it, so it reacts to size changes.
SELECT
pickup_zip,
COUNT(*) AS trips,
ROUND(AVG(fare_amount), 2) AS avg_fare
FROM samples.nyctaxi.trips
GROUP BY pickup_zip
ORDER BY trips DESC
LIMIT 20;The sample table is small, so you may see little change between sizes. That is itself a lesson: small data does not need a large warehouse. For real tables with billions of rows, the differences become visible.
Size versus concurrency
Two different problems can both look like "the warehouse is slow."
- A single query is slow. The fix is usually a larger size.
- Many queries are slow because they queue behind each other. The fix is usually more clusters, set through autoscaling.
Mixing these up is the most common sizing mistake. Raising the size when the real issue is queuing makes every query cost more without removing the queue. Raising the cluster count when one query is slow does nothing, because a single query runs on one cluster.
| Symptom | Likely cause | Adjust |
|---|---|---|
| One heavy query takes minutes | Not enough compute per query | Increase size |
| Query shows spill to disk | Not enough memory per cluster | Increase size |
| Queries wait before starting at busy times | Too many users for the clusters | Increase max clusters |
| Fast alone, slow when others run | Concurrency pressure | Increase max clusters |
| One task dominates the profile | Data skew | Fix the query or data layout |
Mixed workloads
Different jobs often want different sizes. A dashboard that runs short queries for many viewers fits a small size with room to add clusters. A nightly job that rebuilds a large summary fits a larger size that finishes quickly and then stops.
Rather than forcing one warehouse to serve both, consider separate warehouses. This also keeps a heavy job from slowing an interactive dashboard, and it makes cost easier to attribute to each team or purpose.
Edge cases and common errors
- Sizing for the worst query. One rare, heavy query should not set the size for everything. Run that query on a separate larger warehouse, or accept a longer runtime for it.
- Oversizing for small data. A Large warehouse reading a few megabytes is not faster than a Small one. You pay the higher rate for the same runtime.
- Forgetting that idle time costs money. A big warehouse that stays running between queries burns DBUs while doing nothing. Auto stop, covered in the next chapter, limits this.
- Comparing cold and warm runs. A first run after a restart can be slower for reasons unrelated to size. Compare like with like.
- Treating size as a permanent choice. You can change a warehouse's size by editing it. A running warehouse restarts to apply the change, so avoid doing this in the middle of heavy use.
- Ignoring startup time. Serverless warehouses start in seconds. Pro and classic warehouses take longer, and larger ones are not meaningfully faster to start.
Summary of decision criteria
- Choose size by measuring one representative query across sizes.
- Keep increasing while runtime falls by roughly half per step.
- Stop when the gain flattens, because cost then rises faster than speed.
- Use more clusters, not a bigger size, to solve queuing.
- Use separate warehouses for workloads with different needs.
Exercise
A query takes 12 minutes on a Medium warehouse (8x rate). On Large (16x rate) it takes 7 minutes. Compare the cost of the two runs in rate-minutes, and say whether Large is a good choice if cost matters most.
Show answer
Medium costs 12 x 8 = 96 units. Large costs 7 x 16 = 112 units. Large is faster, but it costs about 17% more because the runtime did not halve (it would need to be 6 minutes to break even). If cost matters most, stay on Medium. If waiting five fewer minutes matters more, Large is a reasonable choice.
Exercise
Twenty analysts run short dashboard queries at 9 a.m. Each query is fast when run alone, but at 9 a.m. they wait before starting. Should you raise the warehouse size or the maximum number of clusters, and why?
Show answer
Raise the maximum number of clusters. The queries are fast alone, so each one has enough compute. The delay comes from many queries competing for the same cluster, and extra clusters let them run side by side. A larger size would raise cost without removing the queue.