Skip to main content

Pillar 4 — Efficiency

Principle: Once you've eliminated the work that shouldn't run, make the work that remains as cheap as possible — right-size first, rewrite second.

Efficiency is steps three and four of the optimization hierarchysize then rewrite. It comes after elimination on purpose: there's no point tuning a query you could have cached, or right-sizing a warehouse you could have suspended.

Why it matters

Snowflake warehouse sizes double in credit rate at each step. Running an X-Large where a Small would do is a 16× multiplier on every query in that warehouse — so right-sizing is the highest-multiplier efficiency lever, ahead of any single-query rewrite.

Warehouse size → credit rate

SizeCredits / hourRelative cost
X-Small1
Small2
Medium4
Large8
X-Large1616×
2X-Large3232×
3X-Large6464×
4X-Large128128×

Billing is per-second with a 60-second minimum on resume. The practical implications — and how to pick a size from query shape rather than guesswork — are in the warehouse management guide.

The two efficiency levers

LeverWhen it winschukei mechanism
Right-sizingwarehouse is over- or under-provisioned for its workloadwarehouse sizing / bandit (SetWarehouseSize)
Query rewritingthe query itself scans or computes more than it needsdeterministic rewrite rules

chukei's rewrite rules are equivalence-tested, not LLM-guesses: eliminate SELECT *, push predicates, use APPROX_COUNT_DISTINCT where exactness isn't required, convert OR chains to IN, hoist constants. Every rule ships with positive and negative tests so it never fires when it would change a result.

Efficiency checklist

  • Warehouse sizes are chosen from workload data, not habit.
  • Over-provisioned warehouses are downsized.
  • SELECT * and missing predicates are rewritten or flagged.
  • Rewrites are equivalence-tested before they're trusted.
  • The 60-second resume minimum is accounted for in scheduling.

Find the right size from your own data. The replay simulator models warehouse right-sizing against your real QUERY_HISTORY.