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

WHERE clause OR vs IN

From: "Medi Montaseri" <montaseri(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: WHERE clause OR vs IN
Date: 2007-12-12 22:25:16
Message-ID: 8078a1730712121425u51dca445j6f8f75468cdeda40@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-admin
Hi,

I know this is not exactly admin related, but ... it is simple enough to be
even fun

From a performance point of view, is it better to use OR as in
SELECT expr FROM expr WHERE col=this OR col=that OR col=theOther
Or to use a range of values as in
SELECT expr FROM expr WHERE col in ( val1, val2, ...., valn)

I think the IN range yields a better query plan .... what do you think ?
Thanks
Medi

Responses

pgsql-admin by date

Next:From: Joshua D. DrakeDate: 2007-12-12 22:36:32
Subject: Re: WHERE clause OR vs IN
Previous:From: Peter KoczanDate: 2007-12-12 17:40:33
Subject: Re: Legacy foreign keys

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