Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-performance by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group