Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Harald Fuchs <hari(dot)fuchs(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?
Date: 2011-09-27 10:50:30
Message-ID: CABRT9RAq3WX2FpKPGr2jKxu5XBH37Avf-FtiV9hX6WiyNxm=YQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Sep 27, 2011 at 13:00, Harald Fuchs <hari(dot)fuchs(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Edson Carlos Ericksson Richter 2011-09-27 12:19:32 RES: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?
Previous Message Harald Fuchs 2011-09-27 10:00:57 Re: Does postgresql 9.0.4 use index on PREFIX%SUFFIX queries?