Subject | Re: Bad query optimisation on the MAC? |
---|---|
Author | phil_hhn |
Post date | 2004-11-28T21:13:08Z |
--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
You said that LIKE will be replaced with STARTING WITH by the
optimiser for 1.5 and above. We are using 1.5.1. We also have an index
on the column. Therefore if the optimiser has done its work, it
doesn't matter that we use LIKE because the optimiser will do the
'right' thing.
If this is the case then (other than explicitly specifying STARTING
WITH - which should be unnecesary) there is nothing more we can do;
the code should be running optimally.
I just re-tested the query:
Using LIKE on XP: 640ms; on the MAC: 2203ms
Using STARTING WITH on XP: 640ms; on the MAC: 2158ms
case-sensitive. Was that a typo? Conventionally when someone states
that something is case-sensitive, it means that if for example I'm
searching for 'magic' and the only similar word is 'Magic', then it
will not be found.
I want a case-insensitive search (insensitive to the case of the word
I'm searching for). From what you've just further described about
CONTAINING, it's just what I need.
So I just ran a test using CONTAINING - no significant change in
performance. On XP it takes 578ms, on the MAC 2031ms.
Slightly better performance than using LIKE/STARTING WITH, but nothing
too spectacular.
Thanks
wrote:
> At 01:44 AM 28/11/2004 +0000, you wrote:<helebor@t...>
> >--- In firebird-support@yahoogroups.com, Helen Borrie
> >wrote:optimizer will
> > > LIKE is a dog, as it can't use an index. In v.1.5, the
> > > change LIKE 'anything%' to STARTING WITH, in any case. STARTINGdescribe,
> >WITH does
> > > use an index.
> >
> >Yes, that's what I understood about LIKE. But from what you
> >because we're using 1.5.1 (and have an index on that column), ifthe
> >optimiser has replaced it with STARTING WITH, then I guess we'restuffed.
>ignore an
> I totally miss your point here. If you WANT the optimiser to
> index, there are other things you can do...No no, I don't want to ignore the index.
You said that LIKE will be replaced with STARTING WITH by the
optimiser for 1.5 and above. We are using 1.5.1. We also have an index
on the column. Therefore if the optimiser has done its work, it
doesn't matter that we use LIKE because the optimiser will do the
'right' thing.
If this is the case then (other than explicitly specifying STARTING
WITH - which should be unnecesary) there is nothing more we can do;
the code should be running optimally.
I just re-tested the query:
Using LIKE on XP: 640ms; on the MAC: 2203ms
Using STARTING WITH on XP: 640ms; on the MAC: 2158ms
> > > If you are going to do like '%magic%' then use CONTAININGinstead. It
> > > doesn't use an index, but it is case-sensitive and (I think)smarter
> >thangenuinely
> > > the wildcard search. Confine LIKE to conditions where you
> >needclause
> > > the search to be wildcard.
> >
> >ok, but the search (not mentioned earlier)
>
> "search" = "anything that has to be compared" - hence, a WHERE
> specifies criteria for a search, as does the ON clause of a jonedquery.
>time to
> >does need to ignore case,
> >so what is the overhead with specifying "... where upper(mycolumn)
> >containing 'MAGIC' " ?
>
> upper(mycolumn) is an expression, so there's a calculation each
> uppercase the current column value *before* the search of the stringcan
> begin (one more step possibly). If you are always certain that thesearch
> value will be upper case, probably very little difference - bothways are
> slow because neither can use an index. But of course, if you forcean
> upper case search, it's not case-insensitive...the difference isthat you
> can throw anything at CONTAINING and it will find matches that areeither
> upper or lower case. Pick the horse for the course.Ok, I misunderstood you - you stated earlier that CONTAINING was
case-sensitive. Was that a typo? Conventionally when someone states
that something is case-sensitive, it means that if for example I'm
searching for 'magic' and the only similar word is 'Magic', then it
will not be found.
I want a case-insensitive search (insensitive to the case of the word
I'm searching for). From what you've just further described about
CONTAINING, it's just what I need.
So I just ran a test using CONTAINING - no significant change in
performance. On XP it takes 578ms, on the MAC 2031ms.
Slightly better performance than using LIKE/STARTING WITH, but nothing
too spectacular.
Thanks