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