Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardSQLmerge joinSingle-choice MCQ

Consider this Postgres query. Both columns are indexed by ordinary B-trees on (id). The planner chooses a merge join. Why might the merge join here STILL need an explicit Sort node above one of the index scans rather than just reading the indexes in order?

SELECT a.id FROM a JOIN b ON a.id = b.id WHERE b.status = 'active';