Bird
0
0

Given the table 'orders' with 1 million rows and an index on 'customer_id', what will be the likely effect of this query?

medium📝 query result Q4 of 15
PostgreSQL - Performance Tuning
Given the table 'orders' with 1 million rows and an index on 'customer_id', what will be the likely effect of this query?
SELECT * FROM orders WHERE customer_id = 123;
AThe query will scan the entire table ignoring the index
BThe query will use the index to quickly find matching rows
CThe query will fail due to missing index
DThe query will return no rows because indexes filter data
Step-by-Step Solution
Solution:
  1. Step 1: Understand index usage in WHERE clause

    When a column in WHERE has an index, PostgreSQL uses it to find rows faster.
  2. Step 2: Predict query behavior

    The query will use the index on customer_id to avoid scanning all rows.
  3. Final Answer:

    The query will use the index to quickly find matching rows -> Option B
  4. Quick Check:

    Index use in WHERE = Faster row lookup [OK]
Quick Trick: WHERE on indexed column speeds query [OK]
Common Mistakes:
  • Assuming index is ignored automatically
  • Thinking index causes query failure
  • Believing indexes filter out rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes