Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yn2un-0004j3-MX for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2015 10:38:57 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Yn2un-0003kM-0r for pgsql-hackers@arkaria.postgresql.org; Tue, 28 Apr 2015 10:38:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Yn2ul-0003jG-FN for pgsql-hackers@postgresql.org; Tue, 28 Apr 2015 10:38:55 +0000 Received: from mail.anarazel.de ([217.115.131.40]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Yn2uh-0006h5-V9 for pgsql-hackers@postgresql.org; Tue, 28 Apr 2015 10:38:54 +0000 Received: by mail.anarazel.de (Postfix, from userid 108) id 5F6AB860002; Tue, 28 Apr 2015 12:38:50 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on mail X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.2.5 Received: from anarazel.de (p5DDC52F6.dip0.t-ipconnect.de [93.220.82.246]) (Authenticated sender: andres@anarazel.de) by mail.anarazel.de (Postfix) with ESMTPSA id D6BED860001; Tue, 28 Apr 2015 12:38:45 +0200 (CEST) Received: by anarazel.de (Postfix, from userid 1000) id 5DFEB1009BE; Tue, 28 Apr 2015 12:38:45 +0200 (CEST) Date: Tue, 28 Apr 2015 12:38:45 +0200 From: Andres Freund To: Peter Geoghegan , Tom Lane Cc: hlinnaka , Jeff Janes , Stephen Frost , Dean Rasheed , Bruce Momjian , Pg Hackers Subject: Re: INSERT ... ON CONFLICT UPDATE/IGNORE 4.0, parser/executor stuff Message-ID: <20150428103845.GC19123@awork2.anarazel.de> References: <20150427142849.GD7296@alap3.anarazel.de> <20150427215258.GE7296@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150427215258.GE7296@alap3.anarazel.de> X-Pg-Spam-Score: -4.2 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org On 2015-04-27 23:52:58 +0200, Andres Freund wrote: > On 2015-04-27 16:28:49 +0200, Andres Freund wrote: > > On 2015-04-26 18:02:06 -0700, Peter Geoghegan wrote: > > > * So far, there has been a lack of scrutiny about what the patch does > > > in the rewriter (in particular, to support the EXCLUDED.* pseudo-alias > > > expression) and optimizer (the whole concept of an "auxiliary" > > > query/plan that share a target RTE, and later target ResultRelation). > > > If someone took a close look at that, it would be most helpful. > > > ruleutils.c is also modified for the benefit of EXPLAIN output. This > > > all applies only to the ON CONFLICT UPDATE patch. A committer could > > > push out the IGNORE patch before this was 100% firm. > > > > I'm far from an expert on the relevant regions; but I'm starting to look > > nonetheless. I have to say that on a preliminary look it looks more > > complicated than it has to. > > So, I'm looking. And I've a few questions: > * Why do we need to spread knowledge about speculative inserts that wide? > It's now in 1) Query, 2) ParseState 3) ModifyTable 4) InsertStmt. That > seems a bit wide - and as far as I see not really necessary. That e.g. > transformUpdateStmt() has if (!pstate->p_is_speculative) blocks seems > wrong. > > * afaics 'auxiliary query' isn't something we have under that > name. This isn't really different to what wCTEs do, so I don't think > we need this term here. > > * You refer to 'join like syntax' in a couple places. I don't really see > the current syntax being that join like? Is that just a different > perception of terminology or is that just remnants of earlier > approaches? > > * I am rather unconvinced we need the whole 'ExcludedVar' mechanism. I > don't really see why we need it at all? Can't we 'just' make those > plain vars referring to the normal targetlist "entry"? I feel like I'm > missing something here. > > * The whole dealing with the update clause doesn't seem super > clean. I'm not sure yet how to do it nicer though :( The more I look at approach taken in the executor, the less I like it. I think the fundamental structural problem is that you've chosen to represent the ON CONFLICT UPDATE part as fully separate plan tree node; planned nearly like a normal UPDATE. But it really isn't. That's what then requires you to coordinate knowedge around with p_is_speculative, have these auxiliary trees, have update nodes without a relation, and other similar things. My feeling is that this will look much less ugly if there's simply no UpdateStmt built. I mean, all we need is the target list and the where clause. As far as I can see so far that'll get rid of a lot of structural uglyness. There'll still be some more localized stuff, but I don't think it'll be that bad. I'm actually even wondering if it'd not better off *not* to reuse ExecUpdate(), but that's essentially a separate concern. I'll try to rejigger things roughly in that directions. If you haven't heard of me in three days, call the police. Greetings, Andres Freund -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers