Subject Re: [ib-support] How to optimize LIKE criteria
Author Adrian Roman
> Michael Fung wrote:
>
> > I know MySQL can use index in this case. but IB/FB cannot.
>
> Are you sure about this?
>
> select first_name, last_name
> from employee
> where last_name like 'Ree%';
>
> PLAN (EMPLOYEE INDEX (NAMEX,LN_FN_IDX,LN_FN_DESC_IDX))
>
> FIRST_NAME LAST_NAME
> =============== ====================
>
> Roger Reeves
>
>
> Firebird (and InterBase) have optimised LIKE 'Str%' to use an index for
> as long as I can remember.


Yes, it's able to use an index. Actually, I looked over the code a while ago
(to spot the reason for a bug with 'starting with' - I lost patience before
finding it :-) ) and I noticed that "like 'str%'" will be optimized exactly
like "starting with".


Adrian Roman