Bird
0
0

A query uses an index scan but runs very slowly. Which of these could be a cause?

medium📝 Debug Q7 of 15
PostgreSQL - Performance Tuning
A query uses an index scan but runs very slowly. Which of these could be a cause?
AThe table is empty, so index scan has no rows to read.
BThe index is on a column with many duplicate values, causing many row lookups.
CThe query has no WHERE clause.
DPostgreSQL does not support index scans on large tables.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze index scan performance factors

    If the indexed column has many duplicates, the index scan may fetch many rows, slowing the query.
  2. Step 2: Evaluate other options

    Empty tables run fast; queries without WHERE usually use sequential scan; PostgreSQL supports index scans on large tables.
  3. Final Answer:

    The index is on a column with many duplicate values, causing many row lookups. -> Option B
  4. Quick Check:

    Slow index scan cause = B [OK]
Quick Trick: High duplicates in indexed column slow index scans [OK]
Common Mistakes:
  • Thinking empty tables cause slow queries
  • Assuming no WHERE means index scan
  • Believing PostgreSQL limits index scans by table size

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes