Subject | Re: LIKE operator inside stored procedure |
---|---|
Author | Dorin Vasilescu |
Post date | 2004-04-22T09:36:47Z |
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:
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