Bird
0
0

This query runs slower than expected:

medium📝 Debug Q7 of 15
PostgreSQL - Performance Tuning
This query runs slower than expected:
SELECT * FROM products WHERE price > 1000;
You created an index on price but performance did not improve. What is a likely cause?
APostgreSQL does not support indexes on numeric columns
BThe index on price deletes rows causing errors
CThe query syntax is invalid and causes failure
DThe query uses a range condition which may cause PostgreSQL to prefer a sequential scan
Step-by-Step Solution
Solution:
  1. Step 1: Understand index use with range queries

    Range conditions like price > 1000 sometimes cause PostgreSQL to choose a sequential scan if many rows match.
  2. Step 2: Recognize planner decision

    The planner picks the fastest method; if many rows qualify, scanning whole table can be faster than using index.
  3. Final Answer:

    The query uses a range condition which may cause PostgreSQL to prefer a sequential scan -> Option D
  4. Quick Check:

    Range queries may prefer sequential scan [OK]
Quick Trick: Range filters may cause sequential scans despite indexes [OK]
Common Mistakes:
  • Thinking index deletes rows
  • Assuming query syntax is wrong
  • Believing numeric indexes are unsupported

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes