Re: Where clause efficiency using "IN" - Mailing list pgsql-novice

From Scott Marlowe
Subject Re: Where clause efficiency using "IN"
Date
Msg-id 1098459735.21035.97.camel@localhost.localdomain
Whole thread Raw
In response to Where clause efficiency using "IN"  (Sean Davis <sdavis2@mail.nih.gov>)
List pgsql-novice
On Fri, 2004-10-22 at 09:07, Sean Davis wrote:
> Just a quick general question:  Can someone comment on using where
> clauses like:
>
> (sample = 2 OR sample = 3 OR sample = 4)
>
> as compared to
>
> sample in (2,3,4)
>
> in terms of efficiency?

I believe they are pretty much the same, in that the planner will turn
the in clause you have there into a series of ors.  However, if it is a
subselect, then the planner can use a hashed aggregate method, as long
as the dataset can fit into memory, as defined by some setting, (I think
it's sort_mem, but I'm not completely sure).


pgsql-novice by date:

Previous
From: Steven Klassen
Date:
Subject: Re: Where clause efficiency using "IN"
Next
From: Eric Bieschke
Date:
Subject: User-defined type arrays?