Bird
0
0

Given a table sales with 1 million rows and no indexes, what will be the likely effect of running this query?

medium📝 query result Q4 of 15
PostgreSQL - Performance Tuning
Given a table sales with 1 million rows and no indexes, what will be the likely effect of running this query?
SELECT * FROM sales WHERE product_id = 123;
AThe query will fail due to missing indexes
BThe query will use an index to quickly find matching rows
CThe query will scan the entire table, causing slow performance
DThe query will return no rows because product_id is missing
Step-by-Step Solution
Solution:
  1. Step 1: Understand query execution without indexes

    Without an index on product_id, PostgreSQL must scan all rows to find matches.
  2. Step 2: Predict performance impact

    Scanning 1 million rows is slow and inefficient, causing poor query performance.
  3. Final Answer:

    The query will scan the entire table, causing slow performance -> Option C
  4. Quick Check:

    No index = full table scan = slow query [OK]
Quick Trick: No index means scanning all rows, slowing queries [OK]
Common Mistakes:
  • Assuming query fails without index
  • Thinking query uses index automatically
  • Believing no rows return if index missing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes