Re: BUG #14949: array_append() - performance issues (in update) - Mailing list pgsql-bugs

From Jaroslav Urik
Subject Re: BUG #14949: array_append() - performance issues (in update)
Date
Msg-id CAPouvG5N9UsZOo5x0XyuSWmBJ9cZDmAL=JXpUvLofoF0iw9Cng@mail.gmail.com
Whole thread Raw
In response to Re: BUG #14949: array_append() - performance issues (in update)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #14949: array_append() - performance issues (in update)  (Jaroslav Urik <jarda.urik@gmail.com>)
List pgsql-bugs

Hi,

Thanks for quick response.

Is it possible that there might be something wrong with the table when it was migrated  from 9.6.6 -> 10.1 via pg_dump/restore? I have examined it visually and the data seemed fine..

I will try to provide (not) working example on monday (currently travelling without stable internet connection).

Regards,
Jaroslav Urik

On Wed, Dec 6, 2017, 17:40 Tom Lane <tgl@sss.pgh.pa.us> wrote:
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

pgsql-bugs by date:

Previous
From: steven.winfield@cantabcapital.com
Date:
Subject: BUG #14952: COPY fails to fill in IDENTITY column default value
Next
From: Alexander Korotkov
Date:
Subject: Re: Fwd: [BUGS] pg_trgm word_similarity inconsistencies or bug