Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYX56-0000xF-Oq for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2020 15:44:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jYX55-0000qP-72 for pgsql-bugs@arkaria.postgresql.org; Tue, 12 May 2020 15:44:31 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYX54-0000qI-So for pgsql-bugs@lists.postgresql.org; Tue, 12 May 2020 15:44:31 +0000 Received: from forward501p.mail.yandex.net ([77.88.28.111]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jYX52-0006gL-G8 for pgsql-bugs@lists.postgresql.org; Tue, 12 May 2020 15:44:30 +0000 Received: from mxback29o.mail.yandex.net (mxback29o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::80]) by forward501p.mail.yandex.net (Yandex) with ESMTP id 2242F35001AD; Tue, 12 May 2020 18:44:26 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback29o.mail.yandex.net (mxback/Yandex) with ESMTP id KWKYedxEkk-iPVaOoV1; Tue, 12 May 2020 18:44:25 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zsrv.org; s=mail; t=1589298265; bh=E1Dm7WLeI+SGRg/59cj51o02QwzCbDqR8Nk/DsyBbqo=; h=References:Date:Message-Id:Subject:In-Reply-To:To:From; b=bKtWiWsU0XgpY5kXGntpyPug4lvbhIMNAtvJCbMtibrm4fipuWPKwFE4UGwVwgrII noTyzfO/5X69DUGcWFxg+SOyZnNskv0HsRtw2TL04WT8+PTysM/UxrJs4IiUkmqfU7 YihMF3gdGBRO0hGH42HuOuNcXdPJgaBI1qTweaNk= Authentication-Results: mxback29o.mail.yandex.net; dkim=pass header.i=@zsrv.org Received: by sas2-e76feb6221c0.qloud-c.yandex.net with HTTP; Tue, 12 May 2020 18:44:24 +0300 From: Sergei Kornilov To: "val.janeiko@gmail.com" , "pgsql-bugs@lists.postgresql.org" In-Reply-To: <16430-f03b90a57994b00f@postgresql.org> References: <16430-f03b90a57994b00f@postgresql.org> Subject: Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Tue, 12 May 2020 18:44:24 +0300 Message-Id: <1015851589297759@mail.yandex.ru> Content-Transfer-Encoding: 7bit Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello In one DB connection: => CREATE SEQUENCE resource_surrogate_id_uniquifier_sequence AS integer START WITH 0 INCREMENT BY 1 MINVALUE 0 MAXVALUE 79999 CYCLE CACHE 5; CREATE SEQUENCE => select nextval('resource_surrogate_id_uniquifier_sequence'); nextval --------- 0 => select nextval('resource_surrogate_id_uniquifier_sequence'); nextval --------- 1 => select nextval('resource_surrogate_id_uniquifier_sequence'); nextval --------- 2 => select nextval('resource_surrogate_id_uniquifier_sequence'); nextval --------- 3 In another connection: => select nextval('resource_surrogate_id_uniquifier_sequence'); nextval --------- 5 => select nextval('resource_surrogate_id_uniquifier_sequence'); nextval --------- 6 All as expected. This is how the sequence cache option works - we preallocate values for further use in current connection. regards, Sergei