EXISTS vs IN vs OUTER JOINS

From: Tomasz Myrta <jasiek(at)klaster(dot)net>
To: PgSQL Performance ML <pgsql-performance(at)postgresql(dot)org>
Subject: EXISTS vs IN vs OUTER JOINS
Date: 2002-12-19 10:12:01
Message-ID: 3E019B71.5050901@klaster.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Hi
Few days ago I read, that EXISTS is better than IN, but only if there
are many records (how many?). I was wondering which one is better and
when. Did anyone try to compare these queries doing the same work:

- select * from some_table t
where t.id [not] in (select id from filter);
- select * from some_table t
where [not] exists (select * from filter where id=t.id);
- select * from some_table t
left join filter f using (id)
where f.id is [not] null;

Regards,
Tomasz Myrta

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Josh Berkus 2002-12-19 17:15:36 Re: EXISTS vs IN vs OUTER JOINS
Previous Message scott.marlowe 2002-12-17 16:18:02 Re: Profiling