Bird
0
0

Consider the query:

medium📝 query result Q13 of 15
PostgreSQL - Performance Tuning
Consider the query:
SELECT id, name FROM employees WHERE department = 'Sales';
Which optimization pattern does this query follow?
AUsing a JOIN to combine tables
BUsing ORDER BY to sort results
CUsing a subquery to filter data
DSelecting only needed columns instead of *
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the SELECT clause

    The query selects only 'id' and 'name', not all columns with '*'.
  2. Step 2: Identify the optimization pattern

    Selecting only needed columns reduces data transfer and improves speed.
  3. Final Answer:

    Selecting only needed columns instead of * -> Option D
  4. Quick Check:

    Selective columns = Better performance [OK]
Quick Trick: Avoid SELECT *; pick only columns you need [OK]
Common Mistakes:
  • Confusing JOIN usage with column selection
  • Thinking ORDER BY is always an optimization
  • Assuming subqueries are used here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes