Re: IN or EXISTS?? faster one

From: Lucky Leavell <pgsql(at)UniXpress(dot)com>
To: Prachi Jain <prachijain3(at)rediffmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: IN or EXISTS?? faster one
Date: 2002-12-21 00:11:25
Message-ID: Pine.UW2.4.21.0212201908100.11097-100000@ris7.UniXpress.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 19 Dec 2002, Prachi Jain wrote:

> Hello All,
>
> I am using too many subqueries in my queries. I have read some
> FAQs that using EXISTS is faster than IN. Is that correct??

In general, with any RDBMS, the EXISTS construct is faster because the
subselect need only the first row to satisfy the condition whereas IN must
return all rows from the subselect. (Of course, the query optimizer must
take advantage of that fact ...)

(I am rather new to PostgrSQL but an old hand - in more ways than one <G>-
with commercial Ingres.)

Lucky Leavell

In response to

Browse pgsql-general by date

  From Date Subject
Next Message tom 2002-12-21 00:25:30 Re: table schema causes crash
Previous Message Tom Lane 2002-12-20 23:37:43 Re: table schema causes crash