Subject Re: [firebird-support] Re: Can someone explain to me what's the best way to do this?
Author Uwe Grauer
andrew_s_vaz wrote:

>
> Adam,
>
>
> > I believe (and correct me if I am wrong) that the locate function on
> >a query component is processed by the application. That means that
> >the database will have to return all the records to the application,
> >and the component can then do a search for it. Even if the component
> >does use some form of binary search on the dataset, you have already
> >paid a performance penalty, especially if the database is on a
> >different machine and you have network speed to factor in.
>
> Narf. That would be plain horrible. If that's true, I'll have a loong
> time changing all the searches on my app to do selects insead of locates.
>

Please tell me about this locate thing. Are you talking about FB or
what? (Delphi?)

> hmm.. suddenly I got that "OMGIF" feeling about my app and me.
>
> >
> > The like operator will automatically try and use the available index.
> >
> > select name
> > from employee
> > where name like 'A%'
> >
> > will use the index on 'name', but
> >
> > select name
> > from employee
> > where name like '%a'
> >
> > can not use the index, and so doesn't.
>
> Any known way so the <like '%a'> can use an index? Or simply it just
> can't use it? My users like to do wierd searches and I've already seen
> them doing this kind of search. :-)
>
> >
> > Hope that helps
>
>
> Thanks a lot.
>
> Andrew

No, <like '%a'> cannot use an index.
<like 'a%'> gets translated to "starting with" which will use an index.

Uwe