Subject | Re: [firebird-support] Speed difference between = and LIKE |
---|---|
Author | Helen Borrie |
Post date | 2009-09-24T00:06:35Z |
At 08:59 AM 24/09/2009, you wrote:
select field1 from table1 where field1 like 'abcd%'
select field1 from table1 where field1 starting with 'abcd'
This one is not equivalent to the others since, unlike them, it will match only one value of field1:
select field1 from table1 where field1 = 'abcde'
./heLen
>In Firebird 1.5 is there any difference in speed between these 3 queries ifBecause the engine transforms a LIKE predicate with a trailing wild card into a STARTING WITH predicate, these two are equivalent and can use the index if the optimizer considers it would help:
>there in an index on field1, which is a fixed size (5) text field and if the
>produced number of records will be the same:
>
>select field1 from table1 where field1 = 'abcde'
>
>select field1 from table1 where field1 like 'abcd%'
>
>select field1 from table1 where field1 starting with 'abcd'
>
>It looks not, but just want to make sure.
select field1 from table1 where field1 like 'abcd%'
select field1 from table1 where field1 starting with 'abcd'
This one is not equivalent to the others since, unlike them, it will match only one value of field1:
select field1 from table1 where field1 = 'abcde'
./heLen