Re: WHERE IN vs. WHERE OR OR OR
Posted in 1998
If your values are contiguous, and preferably if there's
a unique index with the leading field being x, then it's
best to do:
select x from y where x between 1 and n
or
select x from y where x >= 1 and x <= n
> Daniel Kirkdorffer wrote:
> >
> > Hi,
> >
> > Using JDBC against and Informix database I was wondering if anyone
> > knew which WHERE clause would be more efficient:
> >
> > SELECT x FROM y WHERE x IN (1, 2, 3,..., n)> >
> > or
> >
> > SELECT x FROM y WHERE x = 1 OR x = 2 OR x = 3 OR ... OR x = n> >
> > (Where x is a primary key)
> >
> > Would the choice be the same if n > 100, or even n > 1000?
> >
> > Any suggestions would be greatly appreciated.
--
Joseph Weinstein Staff Engineer http://www.weblogic.com
See our newsgroups: http://www.weblogic.com/services/newsgroups.html
try weblogic free *with support*: http://www4.weblogic.com/register.html