Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewxEn-0001uw-EL for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Mar 2018 21:50:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1ewxEm-0006cY-DG for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Mar 2018 21:50:08 +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.89) (envelope-from ) id 1ewxBC-0001wR-Ro for pgsql-hackers@lists.postgresql.org; Fri, 16 Mar 2018 21:46:26 +0000 Received: from new1-smtp.messagingengine.com ([66.111.4.221]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ewxB8-0004ws-9b for pgsql-hackers@postgresql.org; Fri, 16 Mar 2018 21:46:25 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id A8709178F; Fri, 16 Mar 2018 17:46:20 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute4.internal (MEProxy); Fri, 16 Mar 2018 17:46:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=UgL5TdynxIzGN3Zhy Ox4lnZ0h/k/Kk8mpuqOuC9Olp4=; b=NMwuYA3lIV9g7VE3sKx1VvLTHRpQXQFCi t1YzpvYfdB1aDroFRDeIHZ+ExxoxZAM8CGtxw6U/nkNtDgbEbV18eBGuE9+u9lpW 0ACFFEg4vHxZR9eRX+dO+35A8Wcj74D2dV/yXzwojadprRVGyjlf1t/ZsvTPALT/ ZaFMaoofDxw2msFJlI8SzisVbe69vwcH0PpjpgqRJfD9taSSBowmJqNozqJlNDN/ Xs++iKlN06ehX7OFyexFYRtfuFsiQqZF4Wuf1ybVSIdPT2enDtRZ+VoKDJuDcsSe qiUyBUn/rnUFkXLh6qF5S+o2A6PcAi9kgvJY2l9iw3vywf1mzgcAA== X-ME-Sender: Received: from alvin.alvh.no-ip.org (unknown [179.56.29.253]) by mail.messagingengine.com (Postfix) with ESMTPA id 01B3524254; Fri, 16 Mar 2018 17:46:20 -0400 (EDT) Received: by alvin.alvh.no-ip.org (Postfix, from userid 1000) id 88AAFCC2; Fri, 16 Mar 2018 18:46:17 -0300 (-03) Date: Fri, 16 Mar 2018 18:46:17 -0300 From: Alvaro Herrera To: Andres Freund Cc: Pavan Deolasee , Etsuro Fujita , Amit Langote , Pg Hackers , Peter Geoghegan Subject: Re: ON CONFLICT DO UPDATE for partitioned tables Message-ID: <20180316214617.dpunmkhhjhvgfxpi@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180316212851.erj4dwmz3ubq3kiq@alap3.anarazel.de> User-Agent: NeoMutt/20170306-137-4415bd-dirty (1.8.0) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund wrote: > Hi, > > On 2018-03-16 18:23:44 -0300, Alvaro Herrera wrote: > > Another thing I noticed is that the split of the ON CONFLICT slot and > > its corresponding projection is pretty weird. The projection is in > > ResultRelInfo, but the slot itself is in ModifyTableState. You can't > > make the projection work without a corresponding slot initialized with > > the correct descriptor, so splitting it this way doesn't make a lot of > > sense to me. > > > > (Now, TBH the split between resultRelInfo->ri_projectReturning and > > ModifyTableState->ps.ps_ResultTupleSlot, which is the slot that the > > returning project uses, doesn't make a lot of sense to me either; so > > maybe there some reason that I'm just not seeing. But I digress.) > > The projections for different child tables / child plans can look > different, therefore it can't be stored in ModifyTableState itself. No? > > The slot's descriptor is changed to be "appropriate" when necessary: > if (slot->tts_tupleDescriptor != RelationGetDescr(resultRelationDesc)) > ExecSetSlotDescriptor(slot, RelationGetDescr(resultRelationDesc)); Grumble. This stuff looks like full of cheats to me, but I won't touch it anyway. > > So I want to propose that we move the slot to be together with the > > projection node that it serves, ie. we put the slot in ResultRelInfo: > > That'll mean we have a good number of additional slots in some cases. I > don't think the overhead of that is going to break the bank, but it's > worth considering. Good point. I think what I should be doing is the same as the returning stuff: keep a tupdesc around, and use a single slot, whose descriptor is changed just before the projection. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services