Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aGshH-0001Gm-Jl for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jan 2016 18:20:35 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aGshG-0006D2-Ki for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jan 2016 18:20:34 +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) (envelope-from ) id 1aGsgd-000587-7r for pgsql-bugs@postgresql.org; Wed, 06 Jan 2016 18:19:55 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aGsga-0001Qm-Cq for pgsql-bugs@postgresql.org; Wed, 06 Jan 2016 18:19:54 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 5AF92860002; Wed, 6 Jan 2016 19:19:50 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p57B4E6AA.dip0.t-ipconnect.de [87.180.230.170]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id B125A860001; Wed, 6 Jan 2016 19:19:46 +0100 (CET) Received: by anarazel.de (Postfix, from userid 1000) id 3497B10BD14; Wed, 6 Jan 2016 19:19:46 +0100 (CET) Date: Wed, 6 Jan 2016 19:19:46 +0100 From: Andres Freund To: Paul Hester Cc: Peter Geoghegan , pgsql-bugs Subject: Re: BUG #13846: INSERT ON CONFLICT consumes sequencers on conflicts Message-ID: <20160106181946.GE7650@awork2.anarazel.de> References: <20160105150227.1117.51692@wrigleys.postgresql.org> <20160105161326.GD7650@awork2.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Pg-Spam-Score: -4.2 (----) 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-01-05 22:04:41 -0700, Paul Hester wrote: > No peek-ahead necessary, when the sequenced column would not be used in the > conflict_target. UPSERTS to dimension tables in a star schema as part of an > OLAP system are very handy, but typically the records in the dimension > tables use a surrogate key based on sequences for maintenance & performance > reasons, and the 'natural' key/value is the only column that would be used > to detect a conflict. In this case, the 'normal' path would be the > conflict_action nearly all the time, and not the insert. If the typical > path was the INSERT, I'd bet the data would be from some event source, and > I guess in that case if there were a key column defaulted with a sequence, > like an order#, it would have to be used to resolve conflicts. But it's > hard to imagine a case in a process flow where you wouldn't already know if > the event existed or not, limiting the need for an UPSERT on event data. It'd be very fragile. You could only do that if the value isn't involved in any unique indexes, if there are no BEFORE triggers (since they need to see the value). > This limitation, of consuming sequencers used for defaults on columns not > necessary to resolve conflict, diminishes the viability for using Postges > UPSERTS for large data warehouses, is all I'm saying (or requires surrogate > keys being 64 bit). Just caught me by surprise in comparison to other > RDBMSs offering some form of UPSERTs that would not consume a sequencer if > its values weren't required to resolve conflicts. If you use normal sequences you already need to cope with gaps in sequences. And ids needing to be 64bits if you're a longer lived business and it's for a a halfway "popular" table, isn't something new. So I don't think addressing this is worth adding code for, especially given the fragility of the situations where it'd be usable. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs