pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ivan E. Panchenko <i.panchenko@postgrespro.ru>
To: pgsql-general@lists.postgresql.org
Subject: Re: Slow alter sequence with PG10.1
Date: Mon, 22 Jan 2018 22:47:46 +0300
Message-ID: <cda1f2c6-6da9-b80d-08cb-293bf7726a32@postgrespro.ru> (raw)
In-Reply-To: <CAKFQuwZ2Xz_v+gzg7PfeC2vjJ3aZ3L=XianwjBLeYdgcW7dSzg@mail.gmail.com>
References: <CACSnzzXZw+QyvRMJ5s9PjFkYDPwWVswb_FtQLY4FVOp0R02Hpg@mail.gmail.com>
	<CAKFQuwZ2Xz_v+gzg7PfeC2vjJ3aZ3L=XianwjBLeYdgcW7dSzg@mail.gmail.com>

I also confirm this problem:

Running Michael's script on 10.1 takes 314 seconds instead of 2.3 
seconds on 9.6.5.

Moreover adding some timing shows that on 10.1 the iteration execution 
time grows linearly with each iteration. (!!)

If we remove ALTER SEQUENCE, the difference is only 2.5 times (5 seconds 
for 10.1 and 2 - for 9.6.5), and the linear growth effect is not observed.

Removing advisory locks saves ~ 200ms in both cases, and still 9.6.5. 
seems faster.


Ivan Panchenko

Postgres Professional
the Russian PostgreSQL Company
+79104339846

22.01.2018 21:55, David G. Johnston пишет:
> On Mon, Jan 22, 2018 at 8:24 AM, Michael Krüger 
> <michael@kruegers.email <mailto:michael@kruegers.email>>wrote:
>
>     Dear community,
>
>     I'm using PG10.1 on CentOS Linux release 7.4.1708 (Core) after
>     upgrading it from PG9.6.6. My application heavily uses sequences
>     and requires different increments of sequence numbers, e.g. a
>     range of 100, 1000 or 5000 numbers, so it is not possible to set a
>     fixed increment on a sequence that can be used by my application.
>
>     With PG10.1 the performance has dropped seriously so that my
>     application becomes unusable. After investigating different
>     aspects, I was able to isolate the issue to be related to the
>     sequences in Postgres 10.1.
>
>     Below shows a simple test script showing the problem:
>
> ​[...]​
>
>
>     On my computer I tried this code on PG9.6.6 and it executed in
>     roughly 3 seconds.
>     When running it on PG10.1 it takes over 7 minutes.
>
>     Further investigation showed that the problem is related to ALTER
>     SEQUENCE...
>
>     I can't believe that PG10.1 was changed that dramatically without
>     providing a workaround or a way to switch to the old PG9.6
>     performance, at least I can't find anything in the documentation.
>
>     Is this a bug?
>
>
> ​Without testing/confirming I'd be inclined to agree that this is a 
> regression for an unusual usage of sequences.  Work was done to make 
> typical use cases of sequences more feature-full and it is quite 
> possible the added effort involved hurts your specific scenario.  I'd 
> expect a hacker to eventually pick this up, confirm the observation, 
> and provide feedback.  This seems like sufficient amount of detail to 
> get the ball rolling.
>
> David J.
>

view thread (13+ messages)  latest in thread

Message-ID: <cda1f2c6-6da9-b80d-08cb-293bf7726a32@postgrespro.ru>
Permalink:  ../cda1f2c6-6da9-b80d-08cb-293bf7726a32@postgrespro.ru/
Also on:    postgresql.org/message-id/cda1f2c6-6da9-b80d-08cb-293bf7726a32@postgrespro.ru

 · 

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-general@postgresql.org
  Cc: i.panchenko@postgrespro.ru
  Subject: Re: Slow alter sequence with PG10.1
  In-Reply-To: <cda1f2c6-6da9-b80d-08cb-293bf7726a32@postgrespro.ru>
  References: <CACSnzzXZw+QyvRMJ5s9PjFkYDPwWVswb_FtQLY4FVOp0R02Hpg@mail.gmail.com> <CAKFQuwZ2Xz_v+gzg7PfeC2vjJ3aZ3L=XianwjBLeYdgcW7dSzg@mail.gmail.com> <cda1f2c6-6da9-b80d-08cb-293bf7726a32@postgrespro.ru>

* 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