Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries? - Mailing list pgsql-general

From Marti Raudsepp
Subject Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?
Date
Msg-id CABRT9RAq3WX2FpKPGr2jKxu5XBH37Avf-FtiV9hX6WiyNxm=YQ@mail.gmail.com
Whole thread Raw
In response to Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?  (Harald Fuchs <hari.fuchs@gmail.com>)
List pgsql-general
On Tue, Sep 27, 2011 at 13:00, Harald Fuchs <hari.fuchs@gmail.com> wrote:
> Pavel Stehule has found a better solution for that:
>
> CREATE OR REPLACE FUNCTION reverse(text) RETURNS text AS $$
>  SELECT string_agg(substring($1 FROM i FOR 1), '')
>  FROM generate_series(length($1), 1, -1) g(i)
> $$ language sql;

I don't want to get into a pissing contest, but I'm not sure by which
criteria this is "better".

When I needed this function, I compared the speed many different
approaches (6 different versions from the mailing lists). The one I
posted above was the winner, a slightly tuned version of the original
by Shoaib Mir. When testing this right now, it takes half the time of
the function you posted, for short non-Unicode strings at least.

Regards,
Marti

pgsql-general by date:

Previous
From: Harald Fuchs
Date:
Subject: Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?
Next
From: "Edson Carlos Ericksson Richter"
Date:
Subject: RES: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?