Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fRfbq-00083l-A5 for pgsql-general@arkaria.postgresql.org; Sat, 09 Jun 2018 15:16:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fRfbo-0000mR-5i for pgsql-general@arkaria.postgresql.org; Sat, 09 Jun 2018 15:16:52 +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.89) (envelope-from ) id 1fRfbn-0000mH-Tt for pgsql-general@lists.postgresql.org; Sat, 09 Jun 2018 15:16:51 +0000 Received: from mx.nsu.ru ([84.237.50.39]) by magus.postgresql.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1fRfbd-00036w-RO for pgsql-general@postgresql.org; Sat, 09 Jun 2018 15:16:50 +0000 Received: from Debian-exim by mx.nsu.ru with local (Exim 4.72) (envelope-from ) id 1fRfba-0003hg-F7 for pgsql-general@postgresql.org; Sat, 09 Jun 2018 22:16:38 +0700 Received: from [84.237.50.47] (helo=regency.nsu.ru) by mx.nsu.ru with esmtp (Exim 4.72) (envelope-from ) id 1fRfba-0003hN-Co; Sat, 09 Jun 2018 22:16:38 +0700 Received: from regency.nsu.ru (localhost [127.0.0.1]) by regency.nsu.ru (8.14.2/8.14.2) with ESMTP id w59FaVH0016714; Sat, 9 Jun 2018 21:36:31 +0600 (NOVT) (envelope-from danfe@regency.nsu.ru) Received: (from danfe@localhost) by regency.nsu.ru (8.14.2/8.14.2/Submit) id w59FaQ37016670; Sat, 9 Jun 2018 22:36:26 +0700 (+07) (envelope-from danfe) Date: Sat, 9 Jun 2018 22:36:26 +0700 From: Alexey Dokuchaev To: Adrian Klaver Cc: pgsql-general@postgresql.org Subject: Re: (2^63 - 1)::bigint => out of range? (because of the double precision) Message-ID: <20180609153626.GA15452@regency.nsu.ru> References: <20180608172323.GA32312@regency.nsu.ru> <20180609122425.GA2680@regency.nsu.ru> <452406d5-fc36-f62e-1675-bf7773e2657b@aklaver.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <452406d5-fc36-f62e-1675-bf7773e2657b@aklaver.com> User-Agent: Mutt/1.4.2.1i X-KLMS-Rule-ID: 3 X-KLMS-Message-Action: skipped X-KLMS-AntiSpam-Status: not scanned, whitelist X-KLMS-AntiPhishing: not scanned, whitelist X-KLMS-AntiVirus: Kaspersky Security 8.0 for Linux Mail Server, version 8.0.1.705, not scanned, whitelist List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, Jun 09, 2018 at 07:20:17AM -0700, Adrian Klaver wrote: > On 06/09/2018 05:24 AM, Alexey Dokuchaev wrote: > >OK, but what about highly volatile tables for come-and-go type of things? > >Think of a session pool, or task queue. I want to use NO CYCLE for this > >kind of tables as it would allow me to never worry about hitting "nextval: > >reached maximum value of sequence" error, recycle ids (because they come > >and go), and still be safe because PK constraint protects me. Any flaws > >in this vision of mine? > > Assuming you meant CYCLE not NO CYCLE, I see no issue. Oh, mea culpa, I meant CYCLE of course (in the quoted paragraph above). > If you do use a sequence with NO CYCLE you can use ALTER SEQUENCE some_seq > RESTART to reset it: > https://www.postgresql.org/docs/10/static/sql-altersequence.html I understand that I can reset it; the idea was to minimize the table and sequence maintenance while allowing it to work, well, forever. Hence the CYCLE idea. Anyway, I've heard you, thanks Adrian. ./danfe