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 1sg718-00FR0B-G5 for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Aug 2024 18:22:10 +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 1sg707-001LYr-JA for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Aug 2024 18:21:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sg707-001LYb-7I for pgsql-hackers@lists.postgresql.org; Mon, 19 Aug 2024 18:21:07 +0000 Received: from mail-yb1-xb33.google.com ([2607:f8b0:4864:20::b33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sg702-000Rfu-Gu for pgsql-hackers@postgresql.org; Mon, 19 Aug 2024 18:21:06 +0000 Received: by mail-yb1-xb33.google.com with SMTP id 3f1490d57ef6-e116ec43a4aso4908445276.0 for ; Mon, 19 Aug 2024 11:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724091661; x=1724696461; 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=amk6U0fF72gONM2fna6xOBhFPQqxAVHBM/TNAwdL298=; b=laiQonSCV3wemlRbdkf/SDTM8SIaDkd/its6g948wOq7xvJf3iTG+/sPx+LtqrfVRU koDj/5LNDUhVkUO8ihwYY+dNESI4uGRajioLBEBy+WE3dR9f6vBtAxYKGBeQ1+tdNwPA 96fmkcmbIIVGWh3rxmIP/0URC6QnB62eyD2ulFZjoX4+/+wmNVa9Bj7ZNjEdiFL15ZmR nd8fOy6hkac+JAkeXSreZAPMRflJ1sq/g5sMq/T+wedNoFNryURClS/I+KVvJK2iubL7 /FG55roi4oVhJwLsfQSqQygA+ZcDXSit8RScZqOTktwOakb8+6UqBOFF8ym//6Qva6LD nukA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724091661; x=1724696461; 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=amk6U0fF72gONM2fna6xOBhFPQqxAVHBM/TNAwdL298=; b=LfPMAUohi4m5AdlObIXUwvcEPtByC+vgjTzzOBzUONtpgGg/UXgQwpMVrjBJ3jGDxc ptPFGEBNvXZH5aASeLxNxsyp/e7tKmAt05vJdS2NW5xIFsZbkDkbBlxUcATC2XDq/yF7 Bo57oeVQLvc3j1KLSM+VuAyecxI8dr5k2datxg/jQEpcPw2QahszLO8db2Av6g1tyHYA nV9SwMcfoijD2T0Rek+JcScXT7FhVZsZPbS5EEb57+mHK6DgrL3AWVjeMEHmcg6b02DF zsbNV+LVhokwjSgKXe4LI86wYBeIIjVhjbpRRqmZUIWgkCsqXkNPBhvKDzIaJrdULzC3 XyLQ== X-Forwarded-Encrypted: i=1; AJvYcCUkkktJhEn3mzQ3XFEtDKQojjitQ/3OW25HSmczJz4Jw8q2K9kYoAX4l8vgis9wlIMYodnqstCSBZVXaSvXo69Avs+WQMJ7NKcezaph X-Gm-Message-State: AOJu0Yy9mSpOeHcJQ9uqkpPwMJYxBTumojkh+a+/9sFAXAEIRXhjCaEJ jCkRpnpxcY5oRzKSC9Gk24MRm6ohN4/uZWFCK/BnM+oTXn0nZIliOVr9fH20EHoOLm8xtCk7GRA 17QXlbQx29Yf5T15xocpdJ4t1aow= X-Google-Smtp-Source: AGHT+IH4T1QeB28uksRy+DBgzQshSmzNV/o0Jf/WkwBUlkBF4cMWeMKyd8b4cGWZ7Tkc0M2r+DHTX1vBeTVGcibkGDA= X-Received: by 2002:a05:690c:6488:b0:6b5:916d:5a8 with SMTP id 00721157ae682-6b5916d08famr85360427b3.23.1724091661404; Mon, 19 Aug 2024 11:21:01 -0700 (PDT) MIME-Version: 1.0 References: <202406191709.jbvpf7d7hl6g@alvherre.pgsql> <1386845.1724086454@sss.pgh.pa.us> <1393410.1724089927@sss.pgh.pa.us> In-Reply-To: <1393410.1724089927@sss.pgh.pa.us> From: Robert Haas Date: Mon, 19 Aug 2024 14:20:46 -0400 Message-ID: Subject: Re: generic plans and "initial" pruning To: Tom Lane Cc: Amit Langote , Alvaro Herrera , Andres Freund , Daniel Gustafsson , David Rowley , PostgreSQL Hackers , Thom Brown 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 19, 2024 at 1:52=E2=80=AFPM Tom Lane wrote: > Robert Haas writes: > > But that seems somewhat incidental to what this thread is about. > > Perhaps. But if we're running into issues related to that, it might > be good to set aside the long-term goal for a bit and come up with > a cleaner answer for intra-session locking. That could allow the > pruning problem to be solved more cleanly in turn, and it'd be > an improvement even if not. Maybe, but the pieces aren't quite coming together for me. Solving this would mean that if we execute a stale plan, we'd be more likely to get a good error and less likely to get a bad, nasty-looking internal error, or a crash. That's good on its own terms, but we don't really want user queries to produce errors at all, so I don't think we'd feel any more free to rearrange the order of operations than we do today. > > Do you have a view on what the way forward might be? > > I'm fresh out of ideas at the moment, other than having a hope that > divide-and-conquer (ie, solving subproblems first) might pay off. Fair enough, but why do you think that the original approach of creating a data structure from within the plan cache mechanism (probably via a call into some new executor entrypoint) and then feeding that through to ExecutorRun() time can't work? Is it possible you latched onto some non-optimal decisions that the early versions of the patch made, rather than there being a fundamental problem with the concept? I actually thought the do-it-at-executorstart-time approach sounded pretty good, even though we might have to abandon planstate tree initialization partway through, right up until Amit started talking about moving ExecutorStart() from PortalRun() to PortalStart(), which I have a feeling is going to create a bigger problem than we can solve. I think if we want to save that approach, we should try to figure out if we can teach the plancache to replan one query from a list without replanning the others, which seems like it might allow us to keep the order of major operations unchanged. Otherwise, it makes sense to me to have another go at the other approach, at least to make sure we understand clearly why it can't work. > Yeah. We are working in an extremely not-green field here, which > means it's a lot easier to see pre-existing reasons why X will not > work than to have confidence that it will work. But hey, if this > were easy then we'd have done it already. Yeah, true. --=20 Robert Haas EDB: http://www.enterprisedb.com