Re: ToDo: fast update of arrays with fixed length fields for PL/pgSQL

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andres Freund <andres(at)2ndquadrant(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ToDo: fast update of arrays with fixed length fields for PL/pgSQL
Date: 2013-10-04 21:18:44
Message-ID: CAFj8pRAeyqhvKNaeaz8V+schvno4grbv-7_o49Q8urNXO4LbFg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

I am sending little bit cleaned patch

there is significant speedup (on example from bug report) - more than 100x
on my Dell D830

postgres=# select fill_2d_array(300,300,1);
fill_2d_array
───────────────
90000
(1 row)

Time: 751.572 ms -- patched
postgres=# \q
bash-4.1$ psql postgres
psql (9.4devel)
Type "help" for help.

postgres=# select fill_2d_array(300,300,2);
fill_2d_array
───────────────
90000
(1 row)

Time: 87453.351 ms -- original

I checked a result and it is same.

Probably there are some issues, because domain tests fails, but these
numbers shows so a significantly faster array update is possible.

Interesting - I did a profiling and I didn't find anything interesting :(

Regards

Pavel

2013/10/3 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>

> Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> writes:
> > If you can do a update of some array in plpgsql now, then you have to
> work
> > with local copy only. It is a necessary precondition, and I am think it
> is
> > valid.
>
> If the proposal only relates to assignments to elements of plpgsql local
> variables, it's probably safe, but it's also probably not of much value.
> plpgsql has enough overhead that I'm doubting you'd get much real-world
> speedup. I'm also not very excited about putting even more low-level
> knowledge about array representation into plpgsql.
>
> regards, tom lane
>

Attachment Content-Type Size
fast-array-update.patch application/octet-stream 7.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2013-10-04 23:52:31 Re: pg_dump insert with column names speedup
Previous Message Oskari Saarenmaa 2013-10-04 19:42:46 Re: [PATCH] pg_upgrade: support for btrfs copy-on-write clones