proposal: prefix function

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: proposal: prefix function
Date: 2018-09-21 08:08:24
Message-ID: CAFj8pRDj04axPu2GgR8fDouDHLfxzyzcdqS0c+NOSfxJkYbRFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

can we implement prefix function for fast test if substr is prefix of some
string?

create or replace function prefix(str text, substr text)
returns boolean as $$
select substr(str, 1, length(substr)) = substr
$$ language sql;

This function can be very effective in C language. Now it should be
implemented with like or regexp, what is significantly more expensive.

Regards

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2018-09-21 08:23:55 Re: [PATCH] Tab completion for ALTER DATABASE … SET TABLESPACE
Previous Message Haribabu Kommi 2018-09-21 07:40:10 Re: Pluggable Storage - Andres's take