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 1qT2Pn-008Bug-VD for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Aug 2023 15:45:04 +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 1qT2Pm-00ASuv-HZ for pgsql-hackers@arkaria.postgresql.org; Mon, 07 Aug 2023 15:45:02 +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 1qT2Pm-00ASuj-8H for pgsql-hackers@lists.postgresql.org; Mon, 07 Aug 2023 15:45:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qT2Pk-0012vE-5B for pgsql-hackers@postgresql.org; Mon, 07 Aug 2023 15:45:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 377FirD9813400; Mon, 7 Aug 2023 11:44:53 -0400 From: Tom Lane To: Robert Haas cc: Amit Langote , Thom Brown , Daniel Gustafsson , Alvaro Herrera , Andres Freund , David Rowley , Jacob Champion , PostgreSQL Hackers Subject: Re: generic plans and "initial" pruning In-reply-to: References: <20221221101846.7zsi7lscnm5ediik@alvherre.pgsql> <1350682.1671635927@sss.pgh.pa.us> <4191508.1674157166@sss.pgh.pa.us> <349124.1674185509@sss.pgh.pa.us> <20230207180855.xy5m4puwh5gzd7xy@awork3.anarazel.de> <1274885.168! 0558101@sss.pgh.pa.us> <9D23D8BB-83EE-451E-95C1-CF42ADB76869@yesql.se> Comments: In-reply-to Robert Haas message dated "Mon, 07 Aug 2023 11:36:32 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <813398.1691423093.1@sss.pgh.pa.us> Date: Mon, 07 Aug 2023 11:44:53 -0400 Message-ID: <813399.1691423093@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > Second, I wondered whether the ordering of cleanup operations could be > an issue. Right now, a node can position cleanup code before, after, > or both before and after recursing to child nodes, whereas with this > design change, the cleanup code will always be run before recursing to > child nodes. Here, I think we have problems. Both ExecGather and > ExecEndGatherMerge intentionally clean up the children before the > parent, so that the child shutdown happens before > ExecParallelCleanup(). Based on the comment and commit > acf555bc53acb589b5a2827e65d655fa8c9adee0, this appears to be > intentional, and you can sort of see why from looking at the stuff > that happens in ExecParallelCleanup(). Right, I doubt that changing that is going to work out well. Hash joins might have issues with it too. Could it work to make the patch force child cleanup before parent, instead of after? Or would that break other places? On the whole though I think it's probably a good idea to leave parent nodes in control of the timing, so I kind of side with your later comment about whether we want to change this at all. regards, tom lane