Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aykMs-0002Gh-8m for pgsql-bugs@arkaria.postgresql.org; Fri, 06 May 2016 18:20:50 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aykMr-0000Ra-Rf for pgsql-bugs@arkaria.postgresql.org; Fri, 06 May 2016 18:20:49 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aykMr-0000RQ-9D for pgsql-bugs@postgresql.org; Fri, 06 May 2016 18:20:49 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aykMk-0008NM-Bv for pgsql-bugs@postgresql.org; Fri, 06 May 2016 18:20:48 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 747852067C for ; Fri, 6 May 2016 14:20:41 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute2.internal (MEProxy); Fri, 06 May 2016 14:20:41 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=smtpout; bh=hRMq5iECFdCw1qbaXd3YpCH/V7w=; b=i8UXw Zk4OI0o4wnI3Ehu8fcQ7jvbyzUUC49hUxGSO2YzIMzxUNYvmgKZ+beq3mlTUqdMs 4n1t0+rW3Uw3U/7PQ/s4Vz1dMeJ3dToj9g0bpP+XZrsnE8T+NlynF0eU9ZpkMG3m 8ZUDb2YaVfGcuWRYwC/z4OsruUxvZAJTyBQYi4= X-Sasl-enc: 2rPdtWAAqd/E0vtZSwHDKgdtvbKcEulFATCsj51YqTS4 1462558841 Received: from intern.anarazel.de (unknown [192.77.237.104]) by mail.messagingengine.com (Postfix) with ESMTPA id 0FD7AC0001A; Fri, 6 May 2016 14:20:41 -0400 (EDT) Date: Fri, 6 May 2016 11:20:40 -0700 From: Andres Freund To: Peter Geoghegan Cc: Francisco Olarte , cwire4@gmail.com, "pgsql-bugs@postgresql.org" Subject: Re: BUG #14126: INSERT ON CONFLICT DO NOTHING auto increments serial primary key when no insert happens. Message-ID: <20160506182040.6bbpacq3ncj777ic@alap3.anarazel.de> References: <20160506065528.2693.64808@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 2016-05-06 11:18:24 -0700, Peter Geoghegan wrote: > On Fri, May 6, 2016 at 6:39 AM, Francisco Olarte wrote: > >> (previous successful key value + number of failed inserts) > >> It seems to me that intuitively the key should only increment on a > >> successful insert, not just an insert statement being executed. For one, > >> this unnecessarily reduces the keyspace available for the column. > > > > I suspect this is "working as designed". The same things happen if you > > do a lot of inserts and then rollback a transaction. This is because > > serial use sequences, which are not mean to generate exact correlative > > values, but to a mean to generate unique keys with very high > > concurrency. > > It is. There have been several -bugs threads on this already. e.g., > the following two: > > http://www.postgresql.org/message-id/flat/CAM3SWZQMfR6Zfe3A0Nr4ddko8xZrijAuQQ=EcGjGeJSs2piAXA@mail.gmail.com#CAM3SWZQMfR6Zfe3A0Nr4ddko8xZrijAuQQ=EcGjGeJSs2piAXA@mail.gmail.com > > http://www.postgresql.org/message-id/flat/CAM3SWZS2jd1Ci2TR2bjBXqZgK3JdoFin9yGbC5TQdYdF12RBuA@mail.gmail.com#CAM3SWZS2jd1Ci2TR2bjBXqZgK3JdoFin9yGbC5TQdYdF12RBuA@mail.gmail.com Maybe we should add a note to the docs then? Andres -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs