Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aykKc-00027n-Ia for pgsql-bugs@arkaria.postgresql.org; Fri, 06 May 2016 18:18:30 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aykKc-00084f-5K for pgsql-bugs@arkaria.postgresql.org; Fri, 06 May 2016 18:18:30 +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 1aykKb-00084P-Lq for pgsql-bugs@postgresql.org; Fri, 06 May 2016 18:18:29 +0000 Received: from mail-yw0-x231.google.com ([2607:f8b0:4002:c05::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1aykKY-0008MN-G3 for pgsql-bugs@postgresql.org; Fri, 06 May 2016 18:18:29 +0000 Received: by mail-yw0-x231.google.com with SMTP id t10so226886619ywa.0 for ; Fri, 06 May 2016 11:18:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=heroku.com; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=d2CrNvMvKTXudApuzFBwQipaFQH0m7ZijXvwf/qd/Ic=; b=un1cyNI58InsskHJBiAnKx737wBM7C/DvnWN8pPT3GzpX2D0JhrSIiKqThNuOnut6X pRBrtkUcaAO/p6tndTpUd/p5vTOV6g7Z3tEXWkC4nTfpUi/7dwfkchqfc3lYCAZIZCl2 fsQIoScXkr2SIfi5TZRbWkt9zbT+Wv7aMddJG+Vha3MZE+oMfUvIhGnzPcqf+RSKgcbg oSjLuT+vEuVjMfGwjLqL+Q/I54r1YkSnPbqAvSLbkR1fnM8C9dS3mNJd0tRUDpgWESRW yXXUC+NhuoSsFc0CXzgRTnpFPS0dwMlNuw/Jx34xjajZ1A5vUmSfADtZ37+hEgkglJmB kB+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=d2CrNvMvKTXudApuzFBwQipaFQH0m7ZijXvwf/qd/Ic=; b=CJLdvLqUEHCQYSx1Bs27/25G1QiVRTP7hvFih8Ww6YzbxcfK3MhOyQ3NE51Ql1Qlb+ temaXieZbIQ8r2I7Prw2mTjtU3wy0Lmnu+ePKVrbGwRgzWvfxSFfHvcnALPxGxEdOB3O FDg4d6F7nKMiOwhuKxuhRAQ9PfoNSXyVWSl6m0C7tINKS9rB+B65vgbqQT2h2ZSVqmzh sLGYOdjonpcyuELmhzRN7iNO84c5trb2NR100Bwwdz1sCcFya+3lx/94UZew80tmLFZR Zxsb2tOaOB2UYKAtApFia2LJKch8SLKFXB9Ho+Yn4+otuh9iuHxTCaeG1wvkW5EGe2eD sEYQ== X-Gm-Message-State: AOPr4FVJu5za9DJSthkPIOGtRz9AtAuNzCHSfjiVJnfj3frNq2dwGJZiByLbTZnG5d4EXRdavyjo1ULostwQ5Mui MIME-Version: 1.0 X-Received: by 10.159.36.46 with SMTP id 43mr13243729uaq.117.1462558704336; Fri, 06 May 2016 11:18:24 -0700 (PDT) Received: by 10.31.236.4 with HTTP; Fri, 6 May 2016 11:18:24 -0700 (PDT) In-Reply-To: References: <20160506065528.2693.64808@wrigleys.postgresql.org> Date: Fri, 6 May 2016 11:18:24 -0700 Message-ID: Subject: Re: BUG #14126: INSERT ON CONFLICT DO NOTHING auto increments serial primary key when no insert happens. From: Peter Geoghegan To: Francisco Olarte Cc: cwire4@gmail.com, "pgsql-bugs@postgresql.org" Content-Type: text/plain; charset=UTF-8 X-Pg-Spam-Score: -2.7 (--) 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 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 -- Peter Geoghegan -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs