Subject Re: usage of = and between in queries
Author Adam
--- In, Vahan Yoghoudjian
<vahan@p...> wrote:
> Hello all
> First of all I want to wish you all the best for the new year....
> Is there any differences in the usage of indexes if in the query
if I
> say
> Method1: where (CODE = 'ABCD')
> Method2: where (CODE between 'ABCD' and 'ABCD')
> The main reason for this is that I have functions that write
> of some queries at run time according to the selected values from
two Lookup
> combos by the user (FROM and TO). So far in these functions I am not
> checking if those two values are equal, whatever the values are (of
> only if TO >= FROM) the second method is used to write the condition...
> If in thise case the first method has better performance I will
> the functions in order to generate this method if both values are equal

That will be fine. Even if FB doesn't internally optimise it, it is an
additional hit to a cached index so it wont be any slower than what
you are doing at the client side. Between is a lot better than IN
(where possible)


where somefield between 1 and 5

is a lot more efficient than

where somefield in (1,2,3,4,5)