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 1ncRSA-0005BG-EH for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Apr 2022 12:41:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ncRS9-0000Wf-AR for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Apr 2022 12:41:33 +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 1ncRS9-0000WU-1X for pgsql-hackers@lists.postgresql.org; Thu, 07 Apr 2022 12:41:33 +0000 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ncRS7-0001BY-71 for pgsql-hackers@postgresql.org; Thu, 07 Apr 2022 12:41:32 +0000 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-e2442907a1so5813597fac.8 for ; Thu, 07 Apr 2022 05:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=OQh19Jym94Dx9LQqeQhMsVuZ19xPK9RMt1psan3h9hQ=; b=hNhbPVNiudbqbQrKzVW6UmY15fT06jatCshWbkyTdB/h/KpmVnfgaREWCqJGX3p94C V+dxzflc6vU7ws5eYFPGmSePlfuzBCe/QKpr12POMp7dNSEB+H3vizPSTBqMxD6faqQY vSCqnG5iyr+7Oqi13jHwNMx2BFwJvErEC6Y2bi8ajbwFOPyJGNBk4B4ATOL1vATtUHgO qrvfMiUs3+w51/zkHvq6hGAhnJHqsVkEBhqWYNK6oRGT7TsNFVUCnxmyf9+maDu2VXBD tGO6LVu79yvVXvwrjNmjXm+G6pBmsxhNsHp9e5BWHK6erOiALstrXmQgQPVY2PwJxhuT lH6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=OQh19Jym94Dx9LQqeQhMsVuZ19xPK9RMt1psan3h9hQ=; b=cBAhhCulr38/Mz5jeII/D6FLfPM3NYiOOFOf5C1KDSpQC1c4zRgpx+TkaverEtArJe r6ko5Bvnsas+sxpHu7S7egwC5McY5J8Omdd1jAdGOxGFsdIiR639AwmWGqQiKasMVp84 otAQiInGTNbm0fkJXBq403yUeH/0aoH4db0gqn8OZn3oBFuoEMw210vlSMThfPvp7L2p Wp5PW+r1nFyVZulDKkVIc/Np+w3pahyPCIRMTRTOo3Ag9u7Ps/maoG2YY/3Odwfjavdx KvN5SMBtWK6VbtovZHePNmN1/YVVrRGV1z6gAu5qkh/8OUtmthAJU9dd9Z4pIeO1rAqF XvxA== X-Gm-Message-State: AOAM531j5tKzezlzywgqchSFQesI36XY3RJ39kU75X0PGmuEDWirmI5c LC4voiGhjNwdloQaHOX6873xPWTXwKHZ6tXKKrU= X-Google-Smtp-Source: ABdhPJy32Z6N5ltDzS9ZjziF67Mkdu1dzh6cI6iKMjAWp+tziVrqfqIjy0yYHz7VTTN/mBM2iUiVyyVi1yCHYfE5ros= X-Received: by 2002:a05:6870:d28d:b0:da:b3f:3234 with SMTP id d13-20020a056870d28d00b000da0b3f3234mr6035451oae.228.1649335289388; Thu, 07 Apr 2022 05:41:29 -0700 (PDT) MIME-Version: 1.0 References: <215356.1647286703@sss.pgh.pa.us> In-Reply-To: From: David Rowley Date: Fri, 8 Apr 2022 00:41:13 +1200 Message-ID: Subject: Re: generic plans and "initial" pruning To: Amit Langote Cc: Robert Haas , Tom Lane , PostgreSQL-development Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, 7 Apr 2022 at 20:28, Amit Langote wrote: > Here's an updated version. In Particular, I removed > part_prune_results list from PortalData, in favor of anything that > needs to look at the list can instead get it from the CachedPlan > (PortalData.cplan). This makes things better in 2 ways: Thanks for making those changes. I'm not overly familiar with the data structures we use for planning around plans between the planner and executor, but storing the pruning results in CachedPlan seems pretty bad. I see you've stashed it in there and invented a new memory context to stop leaks into the cache memory. Since I'm not overly familiar with these structures, I'm trying to imagine why you made that choice and the best I can come up with was that it was the most convenient thing you had to hand inside CheckCachedPlan(). I don't really have any great ideas right now on how to make this better. I wonder if GetCachedPlan() should be changed to return some struct that wraps up the CachedPlan with some sort of executor prep info struct that we can stash the list of PartitionPruneResults in, and perhaps something else one day. Some lesser important stuff that I think could be done better. * Are you also able to put meaningful comments on the PartitionPruneResult struct in execnodes.h? * In create_append_plan() and create_merge_append_plan() you have the same code to set the part_prune_index. Why not just move all that code into make_partition_pruneinfo() and have make_partition_pruneinfo() return the index and append to the PlannerInfo.partPruneInfos List? * Why not forboth() here? i = 0; foreach(stmtlist_item, portal->stmts) { PlannedStmt *pstmt = lfirst_node(PlannedStmt, stmtlist_item); PartitionPruneResult *part_prune_result = part_prune_results ? list_nth(part_prune_results, i) : NULL; i++; * It would be good if ReleaseExecutorLocks() already knew the RTIs that were locked. Maybe the executor prep info struct I mentioned above could also store the RTIs that have been locked already and allow ReleaseExecutorLocks() to just iterate over those to release the locks. David