Bird
0
0

Given a table orders with 1 million rows and an index on customer_id, what is the likely result of this query?

medium📝 query result Q13 of 15
PostgreSQL - Indexing Strategies
Given a table orders with 1 million rows and an index on customer_id, what is the likely result of this query?
SELECT * FROM orders WHERE customer_id = 12345;
AThe query will return no rows because indexes filter data.
BThe query will scan all rows, ignoring the index.
CThe query will fail due to missing index.
DThe query will use the index to quickly find matching rows.
Step-by-Step Solution
Solution:
  1. Step 1: Understand index usage in queries

    When a column is indexed, PostgreSQL uses the index to find matching rows quickly instead of scanning the whole table.
  2. Step 2: Apply to the given query

    The query filters by customer_id, which is indexed, so the index helps find rows efficiently.
  3. Final Answer:

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

    Indexed column = faster search [OK]
Quick Trick: Queries on indexed columns use indexes for speed [OK]
Common Mistakes:
  • Thinking index is ignored automatically
  • Assuming query fails without explicit index hint
  • Believing indexes filter out rows

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes