Re: IN optimization in 7.2 ????? - Mailing list pgsql-general

From Shane Wright
Subject Re: IN optimization in 7.2 ?????
Date
Msg-id 200202181742.g1IHgjF15327@fullerruss.dsvr.co.uk
Whole thread Raw
In response to Re: IN optimization in 7.2 ?????  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-general
IIRC, the subselect is executed only once, but using IN (...) can be slow for
large result sets because the searching in IN is just a sequential scan of
that result set.

Not sure why it'd be faster to crop of the first and last ones though..

--
Shane

On Monday 18 Feb 2002 3:42 pm, Bruce Momjian wrote:
> hubert depesz lubaczewski wrote:
> > On Mon, Feb 18, 2002 at 09:52:19AM -0500, Bruce Momjian wrote:
> > > Not that I know of.
> >
> > strange. what could lead to this results then?
> > i used to think that IN (SELECT ...) is the slowest possible way at all.
> >
> > depesz
> >
> > p.s. of course both select's use indices, and table is vacuumed
>
> I have always wondered this too.  Seems IN evaluates the entire query
> while EXISTS evaluates it for each row, or at least that is how I
> understand it, so saying EXISTS is always faster may be wrong.
> Comments?

pgsql-general by date:

Previous
From: Darren Ferguson
Date:
Subject: Re: SQL question for SQL Gurus
Next
From: wsheldah@lexmark.com
Date:
Subject: Re: Sum of events over an interval; how?