Re: IN or EXISTS?? faster one - Mailing list pgsql-general

From Lucky Leavell
Subject Re: IN or EXISTS?? faster one
Date
Msg-id Pine.UW2.4.21.0212201908100.11097-100000@ris7.UniXpress.com
Whole thread Raw
In response to IN or EXISTS?? faster one  ("Prachi Jain" <prachijain3@rediffmail.com>)
List 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


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: table schema causes crash
Next
From:
Date:
Subject: Re: table schema causes crash