Re: Allow multi-byte characters as escape in SIMILAR TO and SUBSTRING - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Allow multi-byte characters as escape in SIMILAR TO and SUBSTRING
Date
Msg-id 53FB5648.7090806@vmware.com
Whole thread Raw
In response to Re: Allow multi-byte characters as escape in SIMILAR TO and SUBSTRING  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
On 08/25/2014 06:14 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnakangas@vmware.com> writes:
>> On 08/25/2014 04:48 PM, Tom Lane wrote:
>>> [ scratches head... ]  Surely similar_escape is marked immutable, and
>>> will therefore be executed exactly once in either of these formulations,
>>> because the planner will fold the expression to a constant.
>
>> Yeah, just noticed that myself..
>
> ... although, given that, it is also fair to wonder how much the speed of
> similar_escape really matters.  Surely in most use-cases the pattern and
> escape char will be constants.  And, when they are not, wouldn't the
> subsequent parsing work for the regexes dominate the cost of
> similar_escape anyway?
>
> IOW, I'm not sure we should be advising Jeff to duplicate code in
> order to have a fast path.  Keeping it short might be the best goal.

It's certainly not worth bending over backwards for a small performance 
gain here, but I think special-casing a single-byte escape sequence is 
still quite reasonable. It doesn't make the code any longer.

- Heikki




pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: SKIP LOCKED DATA (work in progress)
Next
From: Heikki Linnakangas
Date:
Subject: Re: pg_stat_statements cluttered with "DEALLOCATE dbdpg_p*"