nerdexam
Snowflake

DEA-C02 · Question #52

A Data Engineer enables a result cache at the session level with the following command: ALTER SESSION SET USE_CACHED_RESULT = TRUE; The Engineer then runs the following SELECT query twice without dela

The correct answer is B. The first and second run returned the same results, because the specific SEED value was. Option B is correct because specifying SEED(99) makes the SAMPLE function deterministic - the same seed always produces the same set of rows from the same data. Combined with USE_CACHED_RESULT = TRUE and an unchanged underlying table, Snowflake recognizes the second execution as

Performance Optimization

Question

A Data Engineer enables a result cache at the session level with the following command:

ALTER SESSION SET USE_CACHED_RESULT = TRUE; The Engineer then runs the following SELECT query twice without delay:

SELECT * FROM SNOWFLAKE_SAMPLE_DATA.TPCH_SF1.CUSTOMER SAMPLE(10) SEED (99); The underlying table does not change between executions. What are the results of both runs?

Options

  • AThe first and second run returned the same results, because SAMPLE is deterministic.
  • BThe first and second run returned the same results, because the specific SEED value was
  • CThe first and second run returned different results, because the query is evaluated each time it is
  • DThe first and second run returned different results, because the query uses * instead of an explicit

How the community answered

(32 responses)
  • A
    13% (4)
  • B
    78% (25)
  • C
    3% (1)
  • D
    6% (2)

Explanation

Option B is correct because specifying SEED(99) makes the SAMPLE function deterministic - the same seed always produces the same set of rows from the same data. Combined with USE_CACHED_RESULT = TRUE and an unchanged underlying table, Snowflake recognizes the second execution as identical to the first and returns the cached result rather than re-running the query.

Why the distractors are wrong:

  • A is wrong because SAMPLE alone is not deterministic - without a SEED, it returns a different random subset on each execution. The credit here belongs to the SEED, not SAMPLE itself.
  • C is wrong because the result cache prevents re-evaluation. With caching enabled, an unchanged table, and an identical query string, Snowflake serves the cached result on the second run.
  • D is wrong because using * versus explicit column names has no bearing on result caching or sampling behavior - this is a red herring.

Memory tip: Think of SEED like a random number generator preset - same seed, same output every time. And Snowflake's result cache is like a photocopier: if nothing changed and the query is identical, it hands you the same page without doing the work again. SEED + result cache = identical results both runs.

Topics

#Result Cache#Query Optimization#Sampling#Determinism

Community Discussion

No community discussion yet for this question.

Full DEA-C02 Practice