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 1kSchi-0006yL-03 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 09:04:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kSchg-0007WY-TT for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Oct 2020 09:04:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSchg-0007WR-IU for pgsql-hackers@lists.postgresql.org; Wed, 14 Oct 2020 09:04:12 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kSchd-0004ED-0G for pgsql-hackers@postgresql.org; Wed, 14 Oct 2020 09:04:11 +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) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 9601E1B0029D; Wed, 14 Oct 2020 12:04:06 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1602666246; 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=tJuDXtdv2h7fiLKRBx5CbDBfRM9ZoGEZr2+sfYMzfc0=; b=OBBWsnnehDhgPi0jRNesUBLUa97MZ9sLqc7Rmi/yxe+kGwGI3mGXGhmmbkNQnb+gDY7Bc3 pu+RPyr4ErowFZen4wg6PDjbAO7Ly8JTQIddok9nXe9yLZR3D9A64mIPctemI/j1aq/y73 EpznKpNQfpFjTY5LX00qhL5szwprVohnao7FNGape7n5HlQERqK1sgt2jWSkgE8tHJbwgY apw0fqyD/9ExeFAXcGYb/AiXAFgh+K3kR78A23XHoq33ZKf1b3QDHcmX3qFL4Zz8nQOyqQ sYuOkUOv5q0F9hXGKWfwY1DcTD7RR6mtpx0iF4Im3LXiso4kHQDFnwqYp94ZZQ== Subject: Re: partition routing layering in nodeModifyTable.c To: Amit Langote Cc: Daniel Gustafsson , Etsuro Fujita , Andres Freund , PostgreSQL-development References: <20190718010911.l6xcdv6birtxiei4@alap3.anarazel.de> <424F4298-7826-40DC-B12B-37EFE60EE243@yesql.se> <73fe6ce6-d2a1-bd4b-17cf-9deba4e91467@iki.fi> <19c23dd9-89ce-75a3-9105-5fc05a46f94a@iki.fi> <9bfb949e-21b6-e0f7-c9c9-58710d11e7b1@iki.fi> <3603af69-eb52-4891-5d50-669cb03090a6@iki.fi> From: Heikki Linnakangas Message-ID: <902a656d-e4f2-70bf-f30f-1796d65791fe@iki.fi> Date: Wed, 14 Oct 2020 12:04:06 +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=1602666246; 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=tJuDXtdv2h7fiLKRBx5CbDBfRM9ZoGEZr2+sfYMzfc0=; b=nhIQr91FdNWnMukxpF2qKJgzcKbLNxdVPvJGTZq9b1ClFrYg0zd7cnxUyww7VJt02G/Duh bL7HCJiiWE+zDtZHFtp2kGPFl3LLYs/n4A6q26NjLTXientbj1hzVqHeLM1gZ9rvP4TuAb /s0/KRCV7X5mj0fOkzxbvanao7zcf0v4TFTSDPAiKAJbBC1gMluOGNPbUcKCIAE1p6hUvp U5848azKjcOT/Nv0k5JZhTrIR/8TOOzg0SITPlQEMt4yJzBP01XspzTXoJdt/NjfUMW5g2 YIoXxovERdlUylWzAkMleXY6Eb8I0zJfQjvm4TH3ZyfcY/1io7mG+rNoY4fh1g== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1602666246; a=rsa-sha256; cv=none; b=h6yIHkZgqeBDwr94suuJcOUKV0N9WBSyG0Btfc+qQXQrS3rDsumcdcbkOLF/kGWQvA32nB B1l5TqS912vEV4Qnp1a2OVM+Pe7k8DdMse9HGe8kB0ex1wfLUwSg8qO8LwIE3HbMAHRf39 HtF7Vj1wSx2YwUegqSZv5vMzUmODobdv7MChV80W4ac9A3jLARsMkUroko9MzQPIM7111U kX6ZcpvAdyG/QGb8OYD85kdI2ZHLudGcbS2cOsmbAOK7ts7yGjZw1ZHwd3NzLwOBrmkRSu GhoQG81K2dnCy3D1kBTOt0/oeMI5HDobl+xwx9sfqxxIkY3nPEvxu/ihbMm8Ig== 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 14/10/2020 09:44, Amit Langote wrote: > I like the idea of storing the ResultRelInfo in ForeignScanState, but > it would be better if we can document the fact that an FDW may not > reliably access until IterateDirectModify(). That's because, setting > it in ExecInitForeignScan() will mean *all* result relations must be > initialized during ExecInitModifyTable(), which defies my > lazy-ResultRelInfo-initiailization proposal. As to why why I'm > pushing that proposal, consider that when we'll get the ability to use > run-time pruning for UPDATE/DELETE with [1], initializing all result > relations before initializing the plan tree will mean most of those > ResultRelInfos will be unused, because run-time pruning that occurs > when the plan tree is initialized (and/or when it is executed) may > eliminate most but a few result relations. > > I've attached a diff to v17-0001 to show one way of delaying setting > ForeignScanState.resultRelInfo. The BeginDirectModify function does a lot of expensive things, like opening a connection to the remote server. If we want to optimize run-time pruning, I think we need to avoid calling BeginDirectModify for pruned partitions altogether. I pushed this without those delay-setting-resultRelInfo changes. But we can revisit those changes with the run-time pruning optimization patch. I'll continue with the last couple of patches in this thread. - Heikki