Sub topic 3
Picking a warehouse size
This chapter assumes you know basic SQL, can find your way around the Databricks workspace, and have a rough idea of how cloud compute is billed. It covers what warehouse size means, how to choose one, and the mistakes people commonly make.
What size controls
A SQL warehouse size is a T-shirt label, from 2X-Small up to 4X-Large. The label sets how much compute each cluster in the warehouse has. Every step up roughly doubles the compute, and it roughly doubles the DBUs (Databricks Units, the billing unit for compute) used per hour.
Size changes how fast a single query can run. It does not change how many queries can run at the same time. That is the job of autoscaling, which the next chapter covers.
| Size | Relative compute | Typical use |
|---|---|---|
| 2X-Small | 1x | Light exploration, small tables |
| Small | 4x | Routine analyst queries |
| Medium | 8x | Joins over moderately large tables |
| Large | 16x | Heavy aggregations, large scans |
| 2X-Large and above | 32x and up | Very large scans, strict latency needs |
The multiples in this table are approximate. Check the current pricing page for exact DBU rates for your warehouse type and cloud.
Why a bigger warehouse is not always more expensive
Cost is DBUs per hour multiplied by hours running. If a query is parallel enough to use the extra compute, a warehouse twice as big can finish in about half the time. The total cost then stays close to the same, and you get the answer sooner.
This holds only while the work scales. A small query on a huge warehouse finishes no faster, because it cannot use the extra compute. You pay the higher hourly rate for no gain.
A practical way to choose
- Start with a Small or Medium warehouse for a new workload.
- Run a representative query, such as the aggregation below.
- Open the query profile (a later chapter covers it) and note the run time and how much data was scanned.
- Rerun on the next size up. Compare run times.
- Stop growing when the run time no longer drops by a meaningful amount.
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. On it you will probably see little or no gain from a larger size. That is the "does not scale" case. Test with your own large tables to see real differences.
Common errors
- Sizing for the biggest query. One heavy monthly report should not set the size for all daily work. Use a separate warehouse for it, or run it on a larger one only when needed.
- Adding size to fix concurrency. If many users queue behind each other, a larger size helps only a little. Add clusters through autoscaling instead.
- Ignoring spill. If the query profile shows data spilling to disk, the warehouse is likely too small for that query's memory needs. A size increase often helps here.
- Never revisiting the choice. Data grows. A size that fit last year may be too small now.
Exercise
A single report query takes 8 minutes on a Medium warehouse. You move it to a Large warehouse and it takes 7 minutes 30 seconds. Should you keep the Large warehouse? Why or why not?
Show answer
No. Large uses about twice the DBUs per hour of Medium, but the run time barely dropped, so the query does not scale with more compute. The cost per run roughly doubles with almost no speed gain. Stay on Medium, and look at the query profile for other causes such as a poor join or a missing filter.