โ† All Data Engineering Flashcard Decks

Optimizing Query Performance Flashcards

7 cards from real Data Engineering practice questions. Tap to flip, then mark Knew It or Still Learning โ€” missed cards come back until you master them.

Read the first 7 Optimizing Query Performance flashcards as text
  1. A correlated subquery executed once per outer row is best optimized by:

    Answer: Rewriting it as a join or window function

    Converting row-by-row correlated subqueries into set-based joins avoids repeated execution.

  2. EXPLAIN ANALYZE differs from plain EXPLAIN because it:

    Answer: Actually runs the query and reports real timings

    EXPLAIN ANALYZE executes the query and shows actual versus estimated rows and time.

  3. When estimated rows differ wildly from actual rows in a plan, the fix is usually to:

    Answer: Update/refresh table statistics

    Large estimate-vs-actual gaps point to stale or missing statistics misleading the planner.

  4. Z-ordering / data clustering on commonly filtered columns helps by:

    Answer: Co-locating related values so more files can be skipped

    Clustering sorts related values together, improving data-skipping via file-level min/max stats.

  5. A query joining on columns of mismatched data types (e.g., string vs int) often slows down because:

    Answer: Implicit casting prevents index use

    Type mismatches force implicit conversions that make predicates non-sargable.

  6. Reducing shuffle volume in a distributed aggregation is best achieved by:

    Answer: Pre-aggregating (combiner/map-side) before the shuffle

    Partial aggregation on each node shrinks data before it is shuffled across the network.

  7. An OR condition across two different columns sometimes prevents index use; a common rewrite is:

    Answer: Splitting into a UNION of two indexable queries

    Rewriting OR as a UNION lets each branch use its own index.