Re: Stored procedures when and how: was: Sun acquires MySQL

From: brian <brian(at)zijn-digital(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored procedures when and how: was: Sun acquires MySQL
Date: 2008-01-22 16:26:45
Message-ID: 47961945.9030200@zijn-digital.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Pavel Stehule wrote:
>
> ...
>
> bottleneck is in repeated assign s := s || ..
>
> I will try trick:
>
> create or replace function list(int)
> returns varchar as $$
> begin
> return array_to_string(array(select '<item>' || i || '</item>'
> from generate_series(1, $1) g(i)), '');
> end$$ language plpgsql immutable;
>
> test
> 100, 1.3ms
> 1000, 7.64ms
> 10000, 63ms -- nice I don't need C
> 100000, 350ms
> Regards
>
> Pavel Stehule
>

That's some trick! Thanks for the lessons, Pavel.

b

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adam Rich 2008-01-22 19:11:36 altering foreign keys
Previous Message Pavel Stehule 2008-01-22 15:27:18 Re: Selecting max(pk) is slow on empty set