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 1p4mXO-000545-Bb for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2022 17:24:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p4mXM-0001UA-GJ for pgsql-hackers@arkaria.postgresql.org; Mon, 12 Dec 2022 17:24:20 +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 1p4mXL-0001U1-Gl for pgsql-hackers@lists.postgresql.org; Mon, 12 Dec 2022 17:24:20 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1p4mXH-0000oC-5e for pgsql-hackers@postgresql.org; Mon, 12 Dec 2022 17:24:19 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id B0B195C01BF; Mon, 12 Dec 2022 12:24:10 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Mon, 12 Dec 2022 12:24:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; t=1670865850; x=1670952250; bh=r 0xNpjg0JW4kCDmwqi98hDlV0cx8qjyYMYroCvaiO1s=; b=TgvE++AnR6wpR1HZp hDW8ZD66wrkOPLL/4TYOJ27JsHEC19Lsy1+sjoCSR/mz60N/vTyhAWScGRaDqFwE 2lWn4jDgjLmgTItw09GACr3LsPcamSdM4kYgXGu7lb/GUpm4I0O4m6K9t4ureNz7 4tFmqcU3iwIR0OSmSrH/P9doPnq7RELcaJ7r5GRalzdW3qdHJGYtkh5+j7f9Pi8m vMhoSU0VvUw3g776ZPwKXiPjF/+mAg6DnjoBKHZ8RT+G0VbN34pJC3E/SNm+l5Ck EPfjunVxdKvTDgfeaUINItfYWf7YBgsTI9yTiiKNPWGCnQt7HwCrtle0pw5I/QOu AZJ2Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrvdekgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedvkedtffduffdtffffheffhfejjefhgfeiueeukeejkeff gfdufffhudffffeuveenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 12 Dec 2022 12:24:09 -0500 (EST) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id CFC2EE98; Mon, 12 Dec 2022 18:24:07 +0100 (CET) Date: Mon, 12 Dec 2022 18:24:07 +0100 From: Alvaro Herrera To: Amit Langote Cc: Robert Haas , Jacob Champion , David Rowley , Tom Lane , PostgreSQL-development Subject: Re: generic plans and "initial" pruning Message-ID: <20221212172407.veic522x37kmroli@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2022-Dec-12, Amit Langote wrote: > I started feeling like putting all the new logic being added > by this patch into plancache.c at the heart of GetCachedPlan() and > tweaking its API in kind of unintuitive ways may not have been such a > good idea to begin with. So I started thinking again about your > GetRunnablePlan() wrapper idea and thought maybe we could do something > with it. Let's say we name it GetCachedPlanLockPartitions() and put > the logic that does initial pruning with the new > ExecutorDoInitialPruning() in it, instead of in the normal > GetCachedPlan() path. Any callers that call GetCachedPlan() instead > call GetCachedPlanLockPartitions() with either the List ** parameter > as now or some container struct if that seems better. Whether > GetCachedPlanLockPartitions() needs to do anything other than return > the CachedPlan returned by GetCachedPlan() can be decided by the > latter setting, say, CachedPlan.has_unlocked_partitions. That will be > done by AcquireExecutorLocks() when it sees containsInitialPrunnig in > any of the PlannedStmts it sees, locking only the > PlannedStmt.minLockRelids set (which is all relations where no pruning > is needed!), leaving the partition locking to > GetCachedPlanLockPartitions(). Hmm. This doesn't sound totally unreasonable, except to the point David was making that perhaps we may want this container struct to accomodate other things in the future than just the partition pruning results, so I think its name (and that of the function that produces it) ought to be a little more generic than that. (I think this also answers your question on whether a List ** is better than a container struct.) -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/ "Las cosas son buenas o malas segun las hace nuestra opinión" (Lisias)