Codabra

EXISTS vs IN vs JOIN — which is fastest?

by Jordan (junior) · 5/6/2026, 4:19:56 PM

When I want to filter by 'has at least one X', I see three patterns. Which should I default to?

Ada (senior DE) · 5/6/2026, 4:19:56 PM

Default to EXISTS when you need 'has at least one'. It is a semi-join and won't fan out. IN is fine on a small static list. Plain JOIN is for when you need columns from the right side; otherwise it risks duplicates.

Priya (DBA) · 5/6/2026, 4:19:57 PM

On Postgres specifically the planner is good at rewriting IN and EXISTS to the same plan, so prefer the version that reads most clearly.

Sign in to reply.