pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: jarda.urik@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14949: array_append() - performance issues (in update)
Date: Wed, 06 Dec 2017 11:40:13 -0500
Message-ID: <21684.1512578413@sss.pgh.pa.us> (raw)
In-Reply-To: <20171206105000.21691.37546@wrigleys.postgresql.org>
References: <20171206105000.21691.37546@wrigleys.postgresql.org>

jarda.urik@gmail.com writes:
> I am having (time) issues with UPDATE of Array of INTEGERs:

> Update eg:
> UPDATE id_mng.id_pair SET segment = array_append(segment,7) WHERE
> project_guid = '...' AND id_p IN ( SELECT... )

Hm.  In my hands, an array_append update like that doesn't seem to be
any slower in v10 than prior versions.  I tried both narrow and wide
initial array values, like this:

drop table if exists id_pair;
create table id_pair(segment int[]);

insert into id_pair select array[i,i+1] from generate_series(1,1000000) i;

\timing on
update id_pair set segment = array_append(segment,7);
\timing off

truncate id_pair;
insert into id_pair select array_agg(i) from generate_series(1,1000) i;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;
insert into id_pair select * from id_pair;

\timing on
update id_pair set segment = array_append(segment,7);
\timing off

For me, each of these updates runs in 5 to 6 seconds in any supported
PG version.

Can you provide a self-contained test case that shows what you're
talking about?

			regards, tom lane




view thread (4+ messages)  latest in thread

Message-ID: <21684.1512578413@sss.pgh.pa.us>
Permalink:  ../21684.1512578413@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21684.1512578413@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jarda.urik@gmail.com
  Subject: Re: BUG #14949: array_append() - performance issues (in update)
  In-Reply-To: <21684.1512578413@sss.pgh.pa.us>
  References: <20171206105000.21691.37546@wrigleys.postgresql.org> <21684.1512578413@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox