Subject Re: [firebird-support] (Partially) Comparing records
Author John vd Waeter
Hi Martijn,

> That is correct, UPPER removes the ability to use an index. In
> Firebird 2, you could use expression based indices, in Firebird
> 1.5 or lower, I suggest you add a shadow field, eg: TITLE_UPPER,
> which you populate by using a before insert/update trigger and
> use that to do your compare... Considering the number of books
> with the same title, this should be quick quicker.

Right, yes, that speeds up! :-)

But how about moving conditions from ON to WHERE?

Some timings:

ALL conditions (except the PK) in the ON-clause: 800 ms
HALF of the conditions in the ON, half in the WHERE clause: 380 mS
Wow, looks good!
Now enthousiastic and moving all conditions to the WHERE-clause: 800 mS

I'm trying to move some of the conditions from ON to WHERE, all
producing the same The_result, but all different execution-times.

So still the question is: When to put a condition in the ON or when to
put it in the WHERE clause. And the other question remains: does FB stop
evaluating the ON or WHERE when the first condition evaluates to FALSE
and all other conditions are ANDed with the first? If so, it would make
sense to put a condition that often likely evaluates to False at the
beginning of the expression, wouldn't it?

John