Subject | Re: LIKE operator inside stored procedure |
---|---|
Author | zdeseb |
Post date | 2004-04-22T10:05:54Z |
Thanks, it solved my problem.
But I don't understand why otimizer switch off index optimization. Is
there any VARCHAR value for which is optimal to DO NOT USE index in
this situation?
Zdenek
--- In firebird-support@yahoogroups.com, "Dorin Vasilescu"
<dorin_vas@y...> wrote:
But I don't understand why otimizer switch off index optimization. Is
there any VARCHAR value for which is optimal to DO NOT USE index in
this situation?
Zdenek
--- In firebird-support@yahoogroups.com, "Dorin Vasilescu"
<dorin_vas@y...> wrote:
> The optimizer cannot know how your passed variable value can be, so
> switch off index optimization , I believe
> You can try (this will be optimized):
> UPDATE PATHS
> SET PATH_DELETION = NULL
> WHERE PATH_VALUE STARTING WITH :PARAMETER
>
> and pass the parameter without % at the end
>
>
> --- In firebird-support@yahoogroups.com, "zdeseb" <Zdenek.Sebl@m...>
> wrote:
> > Hello,
> > I have stored procedure with VARCHAR parameter. And I have table
> > PATHS with indexed column PATH_VALUE (VARCHAR).
> >
> > Inside procedure is following statement
> >
> > UPDATE PATHS
> > SET PATH_DELETION = NULL
> > WHERE PATH_VALUE LIKE :PARAMETER;
> >
> > Now I call this procedure
> >
> > EXECUTE PROCEDURE NAME('\\path\hsjha\%');
> >
> > index is not used and table PATHS is sequentialy readed.
> >
> > If I execute statement directly
> >
> > UPDATE PATHS
> > SET PATH_DELETION = NULL
> > WHERE PATH_VALUE LIKE '\\path\hsjha\%';
> >
> > index is used and performance is much better.
> >
> > Is there any way how to write stored procedure which use LIKE
> > operator with parameter/variable on the right site? And of course
> > without horrible performance degradation described above?
> >
> > Thanks,
> > Zdenek