Remove pgpa_gathered_join -- query features make it is obsolete.
authorRobert Haas <rhaas@postgresql.org>
Tue, 15 Jul 2025 16:24:49 +0000 (12:24 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 15 Jul 2025 16:24:49 +0000 (12:24 -0400)
contrib/pg_plan_advice/pg_plan_advice.c
contrib/pg_plan_advice/pgpa_join.c
contrib/pg_plan_advice/pgpa_join.h
contrib/pg_plan_advice/pgpa_output.c
contrib/pg_plan_advice/pgpa_walker.c
contrib/pg_plan_advice/pgpa_walker.h
src/tools/pgindent/typedefs.list

index 71c0c6d270a05d522da0de596ee32288bd5737e1..992e711b916a765d9eb173c7b356a03516e03171 100644 (file)
@@ -324,7 +324,7 @@ pg_plan_advice_generate(PlannedStmt *pstmt)
        context.pstmt = pstmt;
 
        /* Walk the main plan tree. */
-       pgpa_plan_walker(&context, pstmt->planTree, 0, NULL, NULL, NIL);
+       pgpa_plan_walker(&context, pstmt->planTree, 0, NULL, NIL);
 
        /* Main plan tree walk won't reach subplans, so walk those. */
        foreach(lc, pstmt->subplans)
@@ -332,7 +332,7 @@ pg_plan_advice_generate(PlannedStmt *pstmt)
                Plan       *plan = lfirst(lc);
 
                if (plan != NULL)
-                       pgpa_plan_walker(&context, plan, 0, NULL, NULL, NIL);
+                       pgpa_plan_walker(&context, plan, 0, NULL, NIL);
        }
 
        /* Put advice into string form. */
index 8ced1a0c332f072edcceb0e132df7e2ca55e7e49..d7a5c99ffde755f64f4792c01fbb7e163d073147 100644 (file)
@@ -692,39 +692,6 @@ pgpa_add_member_relids(Bitmapset *relids, pgpa_join_member *member)
                return bms_add_member(relids, member->rti);
 }
 
-/*
- * Update a pgpa_gathered_join to include RTIs scanned by the provided
- * plan node.
- */
-void
-pgpa_add_to_gathered_join(pgpa_gathered_join *gathered_join, Plan *plan)
-{
-       Bitmapset  *relids = pgpa_relids(plan);
-       Index           rti;
-
-       /*
-        * In cases where a single node replaces a join -- such as a Result node
-        * that replaces a join between multiple provably-empty relations -- or
-        * when partitionwise join is chosen, we find multiple RTIs for a single
-        * Plan node and must add all of them to the pgpa_gathered_join.
-        */
-       if (relids != NULL)
-       {
-               gathered_join->relids = bms_add_members(gathered_join->relids,
-                                                                                               relids);
-               return;
-       }
-
-       /*
-        * Otherwise, maybe there's a single RTI that this Plan node is scanning.
-        * If so, we should add its RTI to the pgpa_gathered_join; else, there's
-        * nothing to do here.
-        */
-       rti = pgpa_scanrelid(plan);
-       if (rti != 0)
-               gathered_join->relids = bms_add_member(gathered_join->relids, rti);
-}
-
 /*
  * Is this a Result node that has a child?
  */
index 55e2cfbecfa9bc588e2d4c4a13bb1653049736a2..a3bc287e48d81d0860a146ca990e411363ff7632 100644 (file)
@@ -134,16 +134,6 @@ typedef enum
        PGPA_UNROLLED_JOIN
 } pgpa_join_class;
 
-/*
- * Relevant details about which relations are joined beneath a Gather or
- * Gather Merge node.
- */
-typedef struct pgpa_gathered_join
-{
-       bool            is_merge;
-       Bitmapset  *relids;
-} pgpa_gathered_join;
-
 extern pgpa_join_class pgpa_get_join_class(Plan *plan);
 extern pgpa_clumped_join *pgpa_build_clumped_join(PlannedStmt *pstmt,
                                                                                                  Plan *plan,
@@ -160,7 +150,4 @@ extern pgpa_unrolled_join *pgpa_build_unrolled_join(PlannedStmt *pstmt,
 extern void pgpa_destroy_join_unroller(pgpa_join_unroller *join_unroller);
 extern Bitmapset *pgpa_unrolled_join_all_relids(pgpa_unrolled_join *join);
 
-extern void pgpa_add_to_gathered_join(pgpa_gathered_join *gathered_join,
-                                                                         Plan *plan);
-
 #endif
index 632f3dff62172d686ebdcf7b9fb5b4f0eb1bdec8..a8c121d9c8a88b372ace5e06afac2c726598fca3 100644 (file)
@@ -133,20 +133,6 @@ pgpa_output_advice(StringInfo buf, pgpa_plan_walker_context *walker,
                appendStringInfoChar(buf, ')');
        }
 
-       foreach(lc, walker->gathered_joins)
-       {
-               pgpa_gathered_join *gathered_join = lfirst(lc);
-
-               if (buf->len > 0)
-                       appendStringInfoChar(buf, '\n');
-               if (gathered_join->is_merge)
-                       appendStringInfo(buf, "GATHER_MERGE(");
-               else
-                       appendStringInfo(buf, "GATHER(");
-               pgpa_output_relations(&context, buf, gathered_join->relids);
-               appendStringInfoChar(buf, ')');
-       }
-
        foreach(lc, walker->query_features)
        {
                pgpa_query_feature *qf = lfirst(lc);
index e0cd9355a9cebf95bde6112aebfc9cd7a41bf3f2..694961eac866b943777e59427170b942985e04fc 100644 (file)
@@ -22,7 +22,6 @@ void
 pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                                 int join_unroll_level,
                                 pgpa_join_unroller *join_unroller,
-                                pgpa_gathered_join *gathered_join,
                                 List *active_query_features)
 {
        pgpa_join_unroller *outer_join_unroller = NULL;
@@ -64,30 +63,6 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                        pgpa_qf_add_rtis(active_query_features, last_elided_node->relids);
                }
 
-               /*
-                * If we're trying to accumulate the set of relids beneath a Gather or
-                * Gather Merge node, add the relids from the last elided node to the
-                * set. Earlier elided nodes don't need to be mentioned, because we
-                * only want to accumulate RTIs that are part of the same join
-                * problem.
-                *
-                * For instance, if a Gather node appears above a join between p and
-                * q, we do not really care whether p is a plain table, a partitioned
-                * table with children p1 and p2, or a non-inlined subquery containing
-                * arbitrary logic. Knowing that p was joined to q and that the Gather
-                * node appears above that join is enough for us to understand that
-                * any substructure of p and/or q must also appear beneath the Gather
-                * node.
-                */
-               if (gathered_join != NULL)
-               {
-                       ElidedNode *last_elided_node;
-
-                       last_elided_node = list_nth(elided_nodes, num_elided_nodes - 1);
-                       gathered_join->relids = bms_add_members(gathered_join->relids,
-                                                                                                       last_elided_node->relids);
-               }
-
                /*
                 * If there are multiple relids for the elided node, a clumped join
                 * should be built for it exactly once. When there's a join_unroller,
@@ -126,28 +101,8 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                 * flattening it into the parent. In either case, the join order and
                 * join methods beneath the elided node should be described separately
                 * from the join order and methods above the elided node.
-                *
-                * Likewise, we only expect a ppga_gathered_join to mention the RTIs
-                * from the join problem considered immediately beneath the Gather or
-                * Gather Merge node.
                 */
                join_unroller = NULL;
-               gathered_join = NULL;
-       }
-
-       /*
-        * If we've found a Gather or Gather Merge node, prepare to accumulate the
-        * associated RTIs in a new ppga_gathered_join object.
-        */
-       if (IsA(plan, Gather) || IsA(plan, GatherMerge))
-       {
-               if (gathered_join != NULL)
-                       elog(ERROR, "nested Gather or Gather Merge nodes");
-               gathered_join = palloc(sizeof(pgpa_gathered_join));
-               gathered_join->is_merge = IsA(plan, GatherMerge);
-               gathered_join->relids = NULL;
-               context->gathered_joins =
-                       lappend(context->gathered_joins, gathered_join);
        }
 
        /* Check whether the Plan node is a join, and if so, which kind. */
@@ -186,13 +141,6 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                pgpa_unroll_join(context, plan, join_unroller,
                                                 &outer_join_unroller, &inner_join_unroller);
 
-       /*
-        * If we are collecting RTIs below Gather (Merge), add any appropriate
-        * RTIs for this node.
-        */
-       if (gathered_join != NULL)
-               pgpa_add_to_gathered_join(gathered_join, plan);
-
        /*
         * If this is a Gather or Gather Merge node, directly add it to the list
         * of currently-active query features.
@@ -236,12 +184,10 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
        /* Recurse into the outer and inner subtrees. */
        if (plan->lefttree != NULL)
                pgpa_plan_walker(context, plan->lefttree, join_unroll_level,
-                                                outer_join_unroller, gathered_join,
-                                                active_query_features);
+                                                outer_join_unroller, active_query_features);
        if (plan->righttree != NULL)
                pgpa_plan_walker(context, plan->righttree, join_unroll_level,
-                                                inner_join_unroller, gathered_join,
-                                                active_query_features);
+                                                inner_join_unroller, active_query_features);
 
        /*
         * If we created a join unroller up above, then it's also our join to use
@@ -291,7 +237,7 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                         * those are specific to a subquery level.
                         */
                        pgpa_plan_walker(context, ((SubqueryScan *) plan)->subplan,
-                                                        0, NULL, NULL, NIL);
+                                                        0, NULL, NIL);
                        break;
                case T_CustomScan:
                        extraplans = ((CustomScan *) plan)->custom_plans;
@@ -305,7 +251,7 @@ pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
        {
                Plan       *subplan = lfirst(lc);
 
-               pgpa_plan_walker(context, subplan, 0, NULL, NULL,
+               pgpa_plan_walker(context, subplan, 0, NULL,
                                                 pushdown_query_features ? active_query_features : NIL);
        }
 
index 6533a877e0793c0900fc29a0b2ed98689c84e040..65a366ee06ebd0f92d557899dc531a38a204bac0 100644 (file)
@@ -69,7 +69,6 @@ typedef struct pgpa_plan_walker_context
 extern void pgpa_plan_walker(pgpa_plan_walker_context *context, Plan *plan,
                                                         int join_unroll_level,
                                                         pgpa_join_unroller *join_unroller,
-                                                        pgpa_gathered_join *gathered_join,
                                                         List *active_query_features);
 
 extern void pgpa_add_future_feature(pgpa_plan_walker_context *context,
index 9b5d1572fbc225e15b633d9bed2c119a46751125..f8622e276c623d19271a58e45953bb5fbb165bd2 100644 (file)
@@ -4319,7 +4319,6 @@ pgpa_clumped_join
 pgpa_unrolled_join
 pgpa_join_unroller
 pgpa_plan_walker_context
-pgpa_gathered_join
 pgpa_output_context
 pgpa_collected_advice
 pgpa_local_advice_chunk