Thread: Re: Question: consolidating strpos searches?

Re: Question: consolidating strpos searches?

From
Tom Lane
Date:
James Addison <jay@jp-hosting.net> writes:
> In other words: each additional strpos(value, ...) expression
> increased the evaluation time by a similar, significant duration of
> two seconds.  This seems to confirm the basis that each expression is
> currently evaluated separately, by an independent read from the input
> text.

That's correct.  We have not felt a need to try to identify duplicate
function calls: the cost of looking for them would seldom be repaid,
so that such an optimization would be a net loss for most people.
(In your example, they're not even truly duplicates.)

> I'd like to suggest the introduction of a documented multiple string
> matching algorithm[1], to yield results for each of multiple strpos
> calls while only reading through their common input text at-most once.

This seems like something with a pretty narrow audience.  I'd suggest
building it as an extension rather than trying to persuade people
it belongs in core Postgres.

            regards, tom lane