Re: Performance question
Posted in 1998
Guillermo Labatte wrote:
>
> Hi,
> I have been told that
>
> select * from table1 where col between value1 and value2>
> is faster than
>
> select * from table1 where col>=value1 and col<=value2>
> Is that true for Online 5.07?
>
> How about
>
> select * from table1 where col in (value1,value2,value3,value4, ...)>
> vs
>
> select * from table1 where col=value1 or col=value2 or col=value3 or
In 5.0x this was always true. In 7.2x which has a more sophisticated
optimizer, which feels free to rewrite your queries, the optimizer may
replace between with ..<=..>= or relace ..<=..>= with between and
replace an IN clause with a list of OR'd equalities or replace a list
of ORd equalities with an IN clause or it may leave things alone,
depending on data distributions, fragmentation, PDQPRIORITY, etc. So
in 7.2x all bets are off. In general, even in 7.2x, IN is better than
OR and BETWEEN better than a range.
Art S. Kagel