Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVr7y-0000HY-6g for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Oct 2020 07:04:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVr7w-0001Nv-2O for pgsql-hackers@arkaria.postgresql.org; Fri, 23 Oct 2020 07:04:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVr7v-0001Nn-S7 for pgsql-hackers@lists.postgresql.org; Fri, 23 Oct 2020 07:04:39 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVr7o-0002QN-PD for pgsql-hackers@postgresql.org; Fri, 23 Oct 2020 07:04:39 +0000 Received: from [192.168.1.113] (dsl-hkibng22-54faa4-119.dhcp.inet.fi [84.250.164.119]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 615C21B00258; Fri, 23 Oct 2020 10:04:31 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1603436671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=31vpPj9R9+sl5mviYG5Rzxo/bfUoyb35xxanjmaFa1Y=; b=p5/VheTuHckaaxYSnMEQg+13CLFFZl5zxhzszSF1/fbQCjz2TFEb9RQRGeM3RTdgql8VN0 d2MyOvxkxqgH6EX2DrPYFRdDKkO1irxWGnTX9g137o02unqAY8CSyhVzYO7ucESuOcF79F KAEkEHDB4ZhotYOBy6yP+XgdIWPIjQ5jFPxut4zwYMaz6NbBXVCYERMFztj+lxEmNmI5F0 y3C1feSYe3SXllXCvgE+m3HL8uFpv8SWKQXCmwnTCie345QBZMFPQ2SEf96fhgg85Jz7Kv dtB54WeNZ8ktfMgHoYRHASygGB/6V/xh9Xw1YccdDmyWzmTUM8QHyEY/R8xPIg== Subject: Re: partition routing layering in nodeModifyTable.c To: Amit Langote Cc: Alvaro Herrera , Daniel Gustafsson , Etsuro Fujita , Andres Freund , PostgreSQL-development References: <20201017155429.GA9862@alvherre.pgsql> <1d6516c6-9766-3d35-9acd-6358aa51a1ce@iki.fi> From: Heikki Linnakangas Message-ID: <7489c360-ccaf-b2ac-ca56-d68b1caf02db@iki.fi> Date: Fri, 23 Oct 2020 10:04:31 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1603436671; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=31vpPj9R9+sl5mviYG5Rzxo/bfUoyb35xxanjmaFa1Y=; b=YZyIwaA+3DtuEhklSs+3qDKQ+82CLLFjDGEvCTr5SE4Y+wp3mFfvYg1mNO+W91WlxyQ6RH 5R/scxKUG6K5lXg3l34rcL8rLtuib40moHG+4Gsf/4mQLwJ7/ecmGy0mxdSrlUQGNFToEY ZSKsYmYMnZYAnq9V5Y2MsnXVdVKG/EnOitgy8gKm7PS5R4Zlcq6kjctrLsb3/k0jjuOiZB x0+2iCHzVUOSwK5J6vb9UcE7uUTlbCHE9We5sQj1PnX0MWU3s3dBAK1MTTqEdUzPbsMlsv hl61r8iddvz0c4jgsaJTWSzI3/aQEEi2F5thr1gQRgyXPjCQ94TZT8iz37FBvQ== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1603436671; a=rsa-sha256; cv=none; b=jCaZO5dA0af7GVfpqW4MBNlGRf7X99yc42CIWQI80UyvSGei/xwgVj9lzsQlV23e/15xJH PveJU1TlOaGP1sP++QFyH+CBZsvjaaYZEPb3Ub1ekYH3YEM+VTUNcDYd+TppMQ6vaSc/zt VqBS69Cjss+bY4avexxBgd8Y4Cj6aD0Gl4dhHZTJG0Fl0q6p7JQCq/PIRcvYxo6zVopAni xP9Mnyw6VBziHbj0sc6eCciQLDd3YORcMDZ14btEd9RnkEeyMoK+akPDXzUv33f7byPjcN wSoomSesZMReQbhB2SiAej2Pg2rQ2S6fqzWKnf/Tg2OZBHlPVabV7EHsPDWmmw== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 22/10/2020 16:49, Amit Langote wrote: > On Tue, Oct 20, 2020 at 9:57 PM Amit Langote wrote: >> On Mon, Oct 19, 2020 at 8:55 PM Heikki Linnakangas wrote: >>> It's probably true that there's no performance gain from initializing >>> them more lazily. But the reasoning and logic around the initialization >>> is complicated. After tracing through various path through the code, I'm >>> convinced enough that it's correct, or at least these patches didn't >>> break it, but I still think some sort of lazy initialization on first >>> use would make it more readable. Or perhaps there's some other >>> refactoring we could do. >> >> So the other patch I have mentioned is about lazy initialization of >> the ResultRelInfo itself, not the individual fields, but maybe with >> enough refactoring we can get the latter too. > > So, I tried implementing a lazy-initialization-on-first-access > approach for both the ResultRelInfos themselves and some of the > individual fields of ResultRelInfo that don't need to be set right > away. You can see the end result in the attached 0003 patch. This > slims down ExecInitModifyTable() significantly, both in terms of code > footprint and the amount of work that it does. Have you done any performance testing? I'd like to know how much of a difference this makes in practice. Another alternative is to continue to create the ResultRelInfos in ExecInitModify(), but initialize the individual fields in them lazily. Does this patch become moot if we do the "Overhaul UPDATE/DELETE processing"? (https://www.postgresql.org/message-id/CA%2BHiwqHpHdqdDn48yCEhynnniahH78rwcrv1rEX65-fsZGBOLQ%40mail.gmail.com)? - Heikki