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: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin

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 ?


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-2017 The PostgreSQL Global Development Group