Never Touch the Table

The query SELECT user_id, status FROM orders WHERE user_id = $1 uses the index on (user_id), but the plan still shows a heap fetch for every matching row and latency is dominated by random reads. What is the targeted fix?

A

Drop the index on user_id, since a sequential scan reads the table in physical order and avoids random heap access entirely

B

Add status to the index as a trailing key column or an INCLUDE payload, so the index alone answers the query as an index-only scan

C

Create a second standalone index on status so the planner can bitmap-AND the two indexes together and answer the query without the heap

D

Raise the working memory setting so the index and the matching rows both stay resident, which is what removes the random reads