Re: Speeding up loops in pl/pgsql function

From: Santhakumaran <santhkn(at)yahoo(dot)com>
To: Steve Crawford <scrawford(at)pinpointresearch(dot)com>, "Reuven M(dot) Lerner" <reuven(at)lerner(dot)co(dot)il>
Cc: Alex Hunsaker <badalex(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Speeding up loops in pl/pgsql function
Date: 2011-05-26 03:55:53
Message-ID: 726kdq53i20ndcnrt61io437.1306382146325@email.android.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Dkloskxe

Steve Crawford <scrawford(at)pinpointresearch(dot)com> wrote:

>On 05/25/2011 11:45 AM, Reuven M. Lerner wrote:
>> Hi, Alex. You wrote:
>>> Have you tried something like:
>>> SELECT encode(regexp_replace('141142143', '(\d{3})', '\\\1',
>>> 'g')::bytea, 'escape');
>> Hmm, forgot about regexp_replace. It might do the trick, but without
>> a full-blown eval that I can run on the replacement side, it'll be a
>> bit more challenging. But that's a good direction to consider, for sure.
>
>The function given didn't work exactly as written for me but it is on
>the right track. See if this works for you (input validation is left as
>an exercise for the reader...:)):
>
>create or replace function octal_string_to_text(someoctal text) returns
>text as $$
>declare
> binstring text;
>begin
> execute 'select E''' || regexp_replace($1, E'(\\d{3})', E'\\\\\\1',
>'g') || '''' into binstring;
>return binstring;
>end
>$$ language plpgsql;
>
>Cheers,
>Steve
>
>
>--
>Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
>To make changes to your subscription:
>http://www.postgresql.org/mailpref/pgsql-performance

Browse pgsql-performance by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2011-05-26 08:11:18 Re: serveRAID M5014 SAS
Previous Message Craig Ringer 2011-05-26 03:17:50 Re: "error with invalid page header" while vacuuming pgbench data