Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edi4b-0002yG-SP for pgsql-general@arkaria.postgresql.org; Mon, 22 Jan 2018 19:48:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1edi4b-0000MO-B6 for pgsql-general@arkaria.postgresql.org; Mon, 22 Jan 2018 19:48:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1edi4Q-0006y8-EO for pgsql-general@lists.postgresql.org; Mon, 22 Jan 2018 19:47:54 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1edi4M-000307-44 for pgsql-general@lists.postgresql.org; Mon, 22 Jan 2018 19:47:53 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 4E49F21C074F for ; Mon, 22 Jan 2018 22:47:48 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.1.142] (ppp109-252-62-9.pppoe.spdop.ru [109.252.62.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 11F2321C05F2 for ; Mon, 22 Jan 2018 22:47:48 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1516650468; bh=gbxLIogfaaBL2YprOTp4/Z9uWsNSFwg/yP6eT4rsA9Q=; h=Subject:To:References:From:Date:In-Reply-To; b=EHEDuvRsoRfTtS8li5H20mBnVIeviMRM3Ws6kjrtld9nWxQf2S+N5f6LR0mDo3oG1 P/lW5EwVBSlFOnDS9eX60RBeH6QIb9mIqLip9bfED/54DOyt0HTclwjRkhw/w/+2pC XU2AWPi36Vl6onwHc8RSWlhhLeI3DkPqSFFTf4gw= Subject: Re: Slow alter sequence with PG10.1 To: pgsql-general@lists.postgresql.org References: From: "Ivan E. Panchenko" Message-ID: Date: Mon, 22 Jan 2018 22:47:46 +0300 User-Agent: Mozilla/5.0 (X11; Linux i686; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------53328E876E7666D78F5C344F" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------53328E876E7666D78F5C344F Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit 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 > >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. > --------------53328E876E7666D78F5C344F Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

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> 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.


--------------53328E876E7666D78F5C344F--