Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seJad-005zIw-B1 for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 19:23:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1seJab-00CNQr-NP for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Aug 2024 19:23:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1seJab-00CNQj-Ap for pgsql-hackers@lists.postgresql.org; Wed, 14 Aug 2024 19:23:21 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1seJaY-004rXj-Ov for pgsql-hackers@postgresql.org; Wed, 14 Aug 2024 19:23:20 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a7aada2358fso200454266b.0 for ; Wed, 14 Aug 2024 12:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723663398; x=1724268198; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=d9xJEapZjvVrWpANzLtrGmwgI1/pxOo+wQd8V9falqU=; b=AV2Wv0+nvPsO9GUPvMwJTOS9nd1VJB1jKfBkcDWdJUK6gVhDY31LC8Sh9zVPFIP8iL msSmigw3NPwxx8imhkc+nEApdx0buDrhCV6u+8V36NdTtxbcG5wnLN8unzJ+Z85urRJA 3QVmYSVk5L8tzdjFS8kYHFN46JQ+SPpuLEJ6QqcsOtfrr+qCh0cSr5FNv3qWURPU72FT hMJ2YAVU6jk3fihaw1X3KcViLitWLtQatS+pU7/DeywEZWUR6VVpnVSV6veMRhL71+D1 d6A01jhaOZjoammpZCmdK1zGv3aBGcXHaQr7xuiZcfswz7+aLfn8WK/EiSoEC2nxeeae TJVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723663398; x=1724268198; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d9xJEapZjvVrWpANzLtrGmwgI1/pxOo+wQd8V9falqU=; b=ezhmMp7XwqQwksV/ZM8bLne0XFy7n3PuY/nyBWbjQGqfoAEyjWMbPgWVVIQ+KTCkKz FrCPUbYkY59EpOtHs0ooym7FJPGDC71dZQ0UCYXIq5WPyQzvHbQ1v8zL/I1j5jxhHPRY F6kInH6gsvKl9gPsq/gd0hGORZj6YsDEFSW5GXxPlXDYmN/NQh3WOMd4j6/FEDYT2Fq2 NHHr4FJ/+aAGjoThh59G9HGJxZpWx+iFwhpnboXDoCT6ApNdnxXihYxRTn1cqMyNSTVS RSleV9ujv1Pyvb8b19X4qGtY0BSdHYhjm1ZlGxjYCPDcvpOs3F85zRYADIsFFfLYWA4+ wGrg== X-Forwarded-Encrypted: i=1; AJvYcCUsUvAo4eCn8g+HuLo+X7auGS1GhFMg68qasQx+IZtaI2d1D6asAZYeaAIHK24je3uFnYncF81E0t+F0jp97NbXXbYkBCx3GWEgkzoQ X-Gm-Message-State: AOJu0YxHTJgLVrA4b8G0ZK2xXCWLqbtIxyCCSW4dcWMCkXo3RoLplJNM 3Ba/4/3tWIvwyWruH3FwCXyjvHvIgtP7pKlbir+uctnIzCOfvBJ2r1tsOHmxCofMFzOo3JqmqPK IcqiM4qpitUtrDQSAowTBGj7dCbs= X-Google-Smtp-Source: AGHT+IFD/Zw4qd3yGC0y2fMBsaqnOPtR1N44EEmDRZoG6AGU7CfjpVvkTKx732hVqLZ0pZOk4SoFCl7GegF9J9ax5fI= X-Received: by 2002:a17:907:7da1:b0:a7d:c382:bcdf with SMTP id a640c23a62f3a-a837cc368c0mr52369966b.10.1723663396840; Wed, 14 Aug 2024 12:23:16 -0700 (PDT) MIME-Version: 1.0 References: <202406191709.jbvpf7d7hl6g@alvherre.pgsql> In-Reply-To: From: Robert Haas Date: Wed, 14 Aug 2024 15:23:05 -0400 Message-ID: Subject: Re: generic plans and "initial" pruning To: Amit Langote Cc: Alvaro Herrera , Andres Freund , Daniel Gustafsson , David Rowley , Jacob Champion , PostgreSQL Hackers , Thom Brown , Tom Lane Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Aug 12, 2024 at 8:54=E2=80=AFAM Amit Langote wrote: > 1. I went through many iterations of the changes to ExecInitNode() to > return a partially initialized PlanState tree when it detects that the > CachedPlan was invalidated after locking a child table and to > ExecEndNode() to account for the PlanState tree sometimes being > partially initialized, but it still seems fragile and bug-prone to me. > It might be because this approach is fundamentally hard to get right > or I haven't invested enough effort in becoming more confident in its > robustness. Can you give some examples of what's going wrong, or what you think might go wrong? I didn't think there was a huge problem here based on previous discussion, but I could very well be missing some important challenge. > 2. Refactoring needed due to the ExecutorStart() API change especially > that pertaining to portals does not seem airtight. I'm especially > worried about moving the ExecutorStart() call for the > PORTAL_MULTI_QUERY case from where it is currently to PortalStart(). > That requires additional bookkeeping in PortalData and I am not > totally sure that the snapshot handling changes after that move are > entirely correct. Here again, it would help to see exactly what you had to do and what consequences you think it might have. But it sounds like you're talking about moving ExecutorStart() from PortalStart() to PortalRun() and I agree that sounds like it might have user-visible behavioral consequences that we don't want. > 3. The need to add *back* the fields to store the RT indexes of > relations that are not looked at by ExecInitNode() traversal such as > root partitioned tables and non-leaf partitions. I don't remember exactly why we removed those or what the benefit was, so I'm not sure how big of a problem it is if we have to put them back. > About #1, I tend to agree with David that adding complexity around > PlanState tree construction may not be a good idea, because we might > want to rethink Plan initialization code and data structures in the > not too distant future. Like Tom, I don't really buy this. There might be a good reason not to do this in ExecutorStart(), but the hypothetical possibility that we might want to change something and that this patch might make it harder is not it. --=20 Robert Haas EDB: http://www.enterprisedb.com