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
Views: Raw Message | Whole Thread | Download mbox | Resend email
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

Browse pgsql-admin by date

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