Bird
0
0

You see a query plan with Bitmap Index Scan followed by Bitmap Heap Scan, but the query is running very slowly. What could be a likely cause?

medium📝 Debug Q14 of 15
PostgreSQL - Performance Tuning
You see a query plan with Bitmap Index Scan followed by Bitmap Heap Scan, but the query is running very slowly. What could be a likely cause?
AThe index does not exist on the queried column
BThe table is empty, so no rows are fetched
CThe query is missing a WHERE clause
DThe bitmap is too large because the condition matches too many rows, causing inefficient heap fetch
Step-by-Step Solution
Solution:
  1. Step 1: Analyze Bitmap Index Scan and Bitmap Heap Scan behavior

    Bitmap Index Scan creates a bitmap of matching rows; Bitmap Heap Scan fetches rows using that bitmap.
  2. Step 2: Understand performance impact of large bitmap

    If too many rows match, the bitmap is large, causing many random disk accesses and slowing the query.
  3. Final Answer:

    The bitmap is too large because the condition matches too many rows, causing inefficient heap fetch -> Option D
  4. Quick Check:

    Large bitmap = slow Bitmap Heap Scan [OK]
Quick Trick: Large bitmap means many rows matched, slowing fetch [OK]
Common Mistakes:
  • Assuming missing index causes Bitmap Index Scan
  • Thinking missing WHERE clause causes Bitmap Index Scan
  • Believing empty table causes slow scan

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes