Bird
0
0

You want to optimize a query that shows this EXPLAIN output:

hard📝 Application Q8 of 15
PostgreSQL - Performance Tuning
You want to optimize a query that shows this EXPLAIN output:
Bitmap Heap Scan on orders  (cost=4.00..50.00 rows=1000 width=80)
  Bitmap Index Scan on idx_orders_customer_id  (cost=0.00..4.00 rows=1000 width=0)

What does this plan tell you about how the query accesses data?
AIt performs a nested loop join using the index
BIt scans the entire table sequentially without using indexes
CIt sorts the rows before applying the index
DIt uses an index to find matching rows, then fetches them from the table
Step-by-Step Solution
Solution:
  1. Step 1: Understand Bitmap Index Scan

    Bitmap Index Scan finds matching row locations using the index.
  2. Step 2: Understand Bitmap Heap Scan

    Bitmap Heap Scan fetches the actual rows from the table using those locations.
  3. Final Answer:

    It uses an index to find matching rows, then fetches them from the table -> Option D
  4. Quick Check:

    Bitmap scans = index lookup + table fetch [OK]
Quick Trick: Bitmap scans combine index search with table fetch [OK]
Common Mistakes:
  • Thinking bitmap scans are full table scans
  • Assuming sorting happens before index use
  • Confusing bitmap scans with nested loops

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes