skip to content

In a cloud warehouse, how does a result cache differ from a compute cluster's local data cache?

level: middleimportance: should knowfreq 55%

answer

  1. one skips execution, one skips the network
  2. who holds each: service layer versus worker SSD
  3. a commit to the table kills one of them
  4. suspending the cluster kills the other
  5. near-zero compute time is the tell

basics

~20 s

A result cache stores finished query results in the shared service layer and can answer a repeat query without running compute at all. A local data cache stores raw column chunks on a cluster's own SSDs and still requires the cluster to execute the query.

solid answer

~50 s

They sit at different layers and are invalidated by different things. The **result cache** is keyed on the query and the data version, lives in the shared service tier, and returns the previously computed answer with no compute cluster involved — so it is free or near-free and instant, but it only fires on an effectively identical query against unchanged tables, and non-deterministic expressions usually disable it. The **local data cache** lives on each compute cluster's NVMe SSDs and holds raw column chunks pulled from object storage. It does not shortcut execution; it just makes the scan local instead of remote. It is per-cluster, so two clusters querying the same table warm up independently, and it is lost when the cluster suspends or is resized. Practically: result-cache hits show near-zero compute time, data-cache hits show a scan that ran but read little from remote storage.

go deeper

for a junior

Know that repeating a query can be fast for two different reasons: the answer was kept, or the data was kept close to the machine that scanned it.

for a middle

Explain where each cache lives, what key it uses, and what invalidates it — a commit to an input table for one, eviction or cluster shutdown for the other.

for a senior

Use the distinction diagnostically: read a profile, tell a result-cache hit from a warm scan, and explain why a BI tool injecting timestamps produces a permanent cost regression.

for a principal

Set the standard that makes caching pay: stable generated SQL, cluster sizing against the working set, and cost reporting that does not mistake cache hits for genuinely cheap queries.

## Two caches, two layers A separated-architecture warehouse typically has at least two distinct caches on the read path, and confusing them is a common interview stumble because both make a repeated query faster. **The result cache** sits in the shared metadata/service tier, above compute. Its key is essentially the query plus the version of the data it read. On a hit, the stored result set is returned directly. No cluster needs to be running; no bytes are scanned; no compute time is billed. This is why an identical dashboard refresh can return in milliseconds while the cluster is suspended. **The local data cache** sits on each compute cluster, on the workers' attached NVMe SSDs (backed by in-memory page cache). It holds raw column chunks fetched from object storage. On a hit, the query still runs — plan, scan, filter, join, aggregate — it simply reads the bytes locally rather than over the network. Compute time is billed as normal; what you save is remote-read latency and throughput. Some engines add a third layer between them, caching intermediate or partially aggregated results, and all of them cache metadata and file statistics. The two above are the ones interviewers ask about. ## What invalidates each The result cache is invalidated by change to any table the query read. Because the metadata layer knows the current version of every table, a commit to an input table means the cached entry no longer matches the key and the query re-runs. Entries also age out on a retention policy. And a query is usually ineligible in the first place if it is not deterministic — calls to the current timestamp, random values, or session-dependent context mean the same text would not produce the same answer. Cache lookup is normally an exact-ish match on the query, so a changed literal, an added column, or in some engines even differing whitespace is a miss. The local data cache is invalidated by eviction and by cluster lifecycle. Entries are evicted when the working set exceeds the cluster's aggregate SSD capacity, typically on a least-recently-used basis. The whole cache is lost when the cluster suspends, and substantially disturbed when it is resized, because the machines change and file-to-node assignment shifts. New file versions simply become new cache entries; the old chunks age out rather than being explicitly purged. ## Why the difference is operationally visible Several familiar symptoms fall straight out of this: - **The same query is fast on cluster A and slow on cluster B.** Caches are per-cluster. A second cluster reading the same table starts cold even though the data is identical, because the object store is shared but the SSDs are not. - **A dashboard is instant for the first viewer and instant for everyone after, until someone loads data.** Result-cache hits, then the load commits a new table version and the next refresh recomputes. - **A tiny change to the query text costs a full scan.** Result-cache keys are match-based; adding a column or nudging a filter literal produces a key that has never been seen. - **A query that runs at wall-clock speed but bills almost no compute.** A result-cache hit. If your cost report shows a heavily-run query consuming little compute, suspect this rather than assuming the query is cheap to execute. ## Using them deliberately For repeated identical reads — a dashboard tile many users open — the result cache is the cheapest possible outcome, and the way to get it is to make the generated SQL stable: no injected timestamps, no per-user literals where a parameter is not needed, no random cache-busting comment. BI tools that stamp the current time into every query defeat it completely, and that is a real and fixable cost problem. For repeated scans of the same data with different filters or groupings — exploratory analysis, a family of related reports — the result cache never fires but the data cache does, so what matters is keeping the cluster alive and sized so its aggregate local SSD comfortably holds the working set. If the second run of a scan still reads mostly remote bytes, the working set is being evicted and you need a larger cluster, tighter pruning, or a smaller table footprint. A subtlety worth stating in an interview: these caches do not weaken consistency. Both are keyed to a committed table version, so a result-cache hit reflects a genuine committed state of the data, not a stale guess. The freshness question is whether the state is the *latest* one, and the metadata layer answers that on every lookup. ## Summary framing The result cache saves you from running the query. The data cache saves you from crossing the network. One is global and version-scoped; the other is per-cluster and lifecycle-scoped. Cost-wise the first is the one that shows up as compute you never paid for, and the second is the one that shows up as queries that finish in a third of the time on a warm cluster.

  • Which queries can never use a result cache?
    Anything not deterministic for the same inputs: current timestamp or date functions, random values, session or user context, and typically queries over external or streaming sources whose contents the metadata layer cannot version. Any commit to an input table also invalidates an existing entry, so high-churn tables rarely benefit.
  • A BI tool stamps a generated comment with the current time into every query. What does that cost?
    Every query becomes a distinct cache key, so the result cache never hits and each dashboard view runs a real scan on a real cluster. It is a pure cost regression with no benefit, and removing the stamp is usually the single cheapest optimization available on a BI-heavy account.
  • Why does the same query run fast on one cluster and slow on another in the same account?
    The local data cache is per-cluster. Both read the identical files from the shared object store, but only the cluster that has already read them holds them on SSD. The second cluster pays remote reads until its own cache warms.

saying these in an interview costs you the question

  • Treats the result cache and the local data cache as one thing
  • Thinks a data-cache hit means no compute is billed
  • Believes caches are shared between compute clusters
  • Assumes a cached result can be stale relative to a commit
  • Expects the result cache to fire on a semantically equivalent rewrite

context