List:General Discussion« Previous MessageNext Message »
From:Alec.Cawley Date:September 24 2004 8:39am
Subject:Re: Using keys and left()
View as plain text  
"Alexander Newald" <alexander@stripped> wrote on 23/09/2004 19:28:09:

> >
> > Does
> >        select count(id) from test where id like "d%" ;
> > work any better? I would expect it to make better use of the index.
> >
> >        Alec
> >
> 
> Hello,
> 
> yes it works better for sets of data with very few lines with an id 
starting 
> with d. But it takes even longer when more lines are involved.
> 
> I thought using an index will "know" the result??

It is not obvious that the index can look "inside" the LEFT() function, so 
that MySQL has to submit all records to LEFT() and check the results. Why 
it gets slow when you have many LIKE "d%" I cannot understand.

        Alec

Thread
Using keys and left()Alexander Newald23 Sep
  • Re: Using keys and left()Alec.Cawley23 Sep
    • Re: Using keys and left()Alexander Newald23 Sep
      • Re: Using keys and left()Alec.Cawley24 Sep