Bird
0
0

Given this dbt model SQL code:

medium📝 Predict Output Q13 of 15
dbt - Performance Optimization
Given this dbt model SQL code:
SELECT user_id, SUM(amount) AS total
FROM sales
WHERE sale_date > '2024-01-01'
GROUP BY user_id

What is the main reason this query helps reduce warehouse costs compared to selecting all sales data without filtering?
AIt runs the query multiple times to optimize
BIt increases the number of columns scanned
CIt stores the data permanently in the warehouse
DIt reduces the number of rows processed by filtering by date
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the WHERE clause effect

    The WHERE clause filters sales after 2024-01-01, reducing rows processed.
  2. Step 2: Understand impact on warehouse cost

    Fewer rows scanned means less compute and storage cost during query execution.
  3. Final Answer:

    It reduces the number of rows processed by filtering by date -> Option D
  4. Quick Check:

    Filtering rows reduces cost [OK]
Quick Trick: Filter rows early to reduce data scanned [OK]
Common Mistakes:
MISTAKES
  • Thinking more columns scanned reduces cost
  • Confusing storage with query cost
  • Assuming multiple runs optimize cost

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More dbt Quizzes