Re: Manipulating complex types as non-contiguous structures in-memory

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Manipulating complex types as non-contiguous structures in-memory
Date: 2015-05-11 01:36:02
Message-ID: 20150511013602.GK12950@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-05-10 21:09:14 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > I'm not sure what exactly to use as a performance benchmark
> > here. For now I chose
> > SELECT * FROM (SELECT ARRAY(SELECT generate_series(1, 10000))) d, generate_series(1, 1000) repeat(i);
> > that'll hit array_out, which uses iterators.
>
> Hmm, probably those results are swamped by I/O functions though.

I did check with a quick profile, and the iteration itself is a
significant part of the total execution time.

> I'd suggest trying something that exercises array_map(), which
> it looks like means doing an array coercion. Perhaps like so:

> do $$
> declare a int4[];
> x int;
> begin
> a := array(select generate_series(1,1000));
> for i in 1..100000 loop
> x := array_length(a::int8[], 1);
> end loop;
> end$$;

with the loop count set to 10000 instead, I get:
before:
after:
tps = 20.940092 (including connections establishing)
after:
tps = 20.568730 (including connections establishing)

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2015-05-11 01:53:45 Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API)
Previous Message Tom Lane 2015-05-11 01:34:15 Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API)