Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1aGwIv-0003NG-Ik for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jan 2016 22:11:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1aGwIu-0001lG-Ec for pgsql-bugs@arkaria.postgresql.org; Wed, 06 Jan 2016 22:11:40 +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 1aGwIt-0001iw-GI for pgsql-bugs@postgresql.org; Wed, 06 Jan 2016 22:11:39 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by makus.postgresql.org with esmtp (Exim 4.84) (envelope-from ) id 1aGwIq-0006Gq-IC for pgsql-bugs@postgresql.org; Wed, 06 Jan 2016 22:11:38 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id D989E860002; Wed, 6 Jan 2016 23:11:34 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-5.6 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 78AE9860001; Wed, 6 Jan 2016 23:11:31 +0100 (CET) Received: by anarazel.de (Postfix, from userid 1000) id 0A37910BD14; Wed, 6 Jan 2016 23:11:31 +0100 (CET) Date: Wed, 6 Jan 2016 23:11:30 +0100 From: Andres Freund To: Paul Cc: Peter Geoghegan , pgsql-bugs Subject: Re: BUG #13846: INSERT ON CONFLICT consumes sequencersonconflicts Message-ID: <20160106221130.GG7650@awork2.anarazel.de> References: <20160105150227.1117.51692@wrigleys.postgresql.org> <20160105161326.GD7650@awork2.anarazel.de> <20160106181946.GE7650@awork2.anarazel.de> <568d8060.291cb60a.e8a06.ffff9d00@mx.google.com> <568d8e74.d1a9ca0a.d9558.ffff9026@mx.google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <568d8e74.d1a9ca0a.d9558.ffff9026@mx.google.com> 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 Hi, On 2016-01-06 15:00:17 -0700, Paul wrote: > I’m looking at math more like a single Fact table having 500 million > records, with 10 dimension columns. If INTs were used for the > dimension columns, that’s 20GB. > If I had to change those dimension columns to BIGINTs, that’s > 40GB. This can impact how much you can fit into server memory, where > olaps like to live, and just slow down moving stuff around between > memory and disk and over the network and backups, etc. Row headers, padding & alignment makes that absolutely different in reality. It's like a sub 20% difference. And in pretty much all the cases with sufficient insertion rates you're going to want bigints anyway. If there's few rows it doesn't matter anyway. > On a technical note, why is the following flow considered ‘fragile’? The fragility comes from the fact that it'd only be used in a subset of cases. E.g. if a BEFORE trigger is present the to-be-inserted rows needs to be "materialized" to be presented to the trigger. > 1) Evaluate only columns used in conflict_target > a. Conflict-resolving Columns with default nextval() increment the corresponding sequencer > i. And in this case, there were never be conflicts by definition, so > ON CONFLICT can always be ignored Wrong. Rows with sequences can very well conflict, there's nothing forcing sequences to always be used. Also note that sequence default values aren't in any way different from other default values, and that relevant pieces of code currently don't know whether a default value is a nextval or not. > 2) If conflict, DO UPDATE > a. If nextval()-defaulted column used in conflict_target, we never get here > b. Defaults never evaluated > 3) Else Evaluate remaining columns not used in conflict_target and INSERT > a. Columns with nextval() increment their corresponding sequencer Perhaps read the code, and prototype it? I can tell you that it'd be a significant amount of work, and that I'm personally absolutely not interested in investing significant amounts time into it. But that doesn't have to stop *you*. Anyway, EOD for me. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs