summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2025-07-16 13:52:02 +0000
committerRobert Haas2025-07-16 13:52:02 +0000
commit3643dd3a603836fc3492ef9fbd43e017cd1b1f4d (patch)
treef52261be59c05ecc13a8af70d376079a98f4a73b
parentefc658c775a6e5f4542fa51a164dfa0fb2ff2b17 (diff)
renaming, phase 2
-rw-r--r--contrib/pg_plan_advice/pgpa_output.c46
-rw-r--r--contrib/pg_plan_advice/pgpa_scan.h64
-rw-r--r--src/tools/pgindent/typedefs.list16
3 files changed, 95 insertions, 31 deletions
diff --git a/contrib/pg_plan_advice/pgpa_output.c b/contrib/pg_plan_advice/pgpa_output.c
index 4c637d6b14..43b82f028a 100644
--- a/contrib/pg_plan_advice/pgpa_output.c
+++ b/contrib/pg_plan_advice/pgpa_output.c
@@ -20,7 +20,7 @@ typedef struct pgpa_output_context
const char **rt_identifiers;
StringInfo buf;
List *unrolled_joins[NUM_PGPA_JOIN_STRATEGY];
- List *scans[NUM_PGPA_CLUMP_JOIN_STRATEGY];
+ List *scans[NUM_PGPA_SCAN_STRATEGY];
List *query_features[NUM_PGPA_QF_TYPES];
int wrap_column;
} pgpa_output_context;
@@ -32,8 +32,8 @@ static void pgpa_output_join_member(pgpa_output_context *context,
static void pgpa_output_relations(pgpa_output_context *context, StringInfo buf,
Bitmapset *relids);
-static char *pgpa_cstring_join_clump_strategy(pgpa_join_clump_strategy strategy);
static char *pgpa_cstring_join_strategy(pgpa_join_strategy strategy);
+static char *pgpa_cstring_scan_strategy(pgpa_scan_strategy strategy);
static void pgpa_maybe_linebreak(StringInfo buf, int wrap_column);
@@ -148,9 +148,9 @@ pgpa_output_advice(StringInfo buf, pgpa_plan_walker_context *walker,
* types as well as join types, and the question of how to handle that
* deserves more thought.
*/
- for (int c = 0; c < NUM_PGPA_CLUMP_JOIN_STRATEGY; ++c)
+ for (int c = 0; c < NUM_PGPA_SCAN_STRATEGY; ++c)
{
- char *cstrategy = pgpa_cstring_join_clump_strategy(c);
+ char *cstrategy = pgpa_cstring_scan_strategy(c);
bool first = true;
if (context.scans[c] == NIL)
@@ -346,25 +346,6 @@ pgpa_output_relations(pgpa_output_context *context, StringInfo buf,
}
/*
- * Get a C string that corresponds to the specified join clump strategy.
- */
-static char *
-pgpa_cstring_join_clump_strategy(pgpa_join_clump_strategy strategy)
-{
- switch (strategy)
- {
- case JSTRAT_CLUMP_DEGENERATE:
- return "DEGENERATE";
- case JSTRAT_CLUMP_FOREIGN:
- return "FOREIGN";
- case JSTRAT_CLUMP_PARTITIONWISE:
- return "PARTITIONWISE";
- }
-
- Assert(false);
-}
-
-/*
* Get a C string that corresponds to the specified join strategy.
*/
static char *
@@ -390,6 +371,25 @@ pgpa_cstring_join_strategy(pgpa_join_strategy strategy)
}
/*
+ * Get a C string that corresponds to the specified scan strategy.
+ */
+static char *
+pgpa_cstring_scan_strategy(pgpa_scan_strategy strategy)
+{
+ switch (strategy)
+ {
+ case JSTRAT_CLUMP_DEGENERATE:
+ return "DEGENERATE";
+ case JSTRAT_CLUMP_FOREIGN:
+ return "FOREIGN";
+ case JSTRAT_CLUMP_PARTITIONWISE:
+ return "PARTITIONWISE";
+ }
+
+ Assert(false);
+}
+
+/*
* Insert a line break into the StringInfoData, if needed.
*
* If wrap_column is zero or negative, this does nothing. Otherwise, we
diff --git a/contrib/pg_plan_advice/pgpa_scan.h b/contrib/pg_plan_advice/pgpa_scan.h
new file mode 100644
index 0000000000..5724af1c92
--- /dev/null
+++ b/contrib/pg_plan_advice/pgpa_scan.h
@@ -0,0 +1,64 @@
+/*-------------------------------------------------------------------------
+ *
+ * pgpa_scan.h
+ * analysis of scans in Plan trees
+ *
+ * Note that our definition of "scan" is extremely broad. It includes
+ * (1) single plan nodes that scan multiple RTIs, such as a degenerate
+ * Result node that replaces what would otherwise have been a join, and
+ * (2) Append and MergeAppend nodes implementing a partitionwise scan
+ * or a partitionwise join.
+ *
+ * Copyright (c) 2016-2025, PostgreSQL Global Development Group
+ *
+ * contrib/pg_plan_advice/pgpa_scan.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef PGPA_SCAN_H
+#define PGPA_SCAN_H
+
+#include "nodes/plannodes.h"
+
+/*
+ * Certain types of plan nodes can join any number of input relations in
+ * a single step; we call these "clumped joins".
+ *
+ * For our purposes, the important thing about a clumped join is that we
+ * can't meaningfully speak about the order in which tables are joined
+ * within a single clump. For example, if the optimizer chooses a
+ * partitionwise join on tables A and B, we can't say whether A was joined
+ * to B or whether B was joined to A; instead, each pair of child tables
+ * has its own join order. Likewise, if a foreign data wrapper pushes a
+ * join to the remote side, we don't know the join order.
+ *
+ * JSTRAT_CLUMP_DEGENERATE refers to the case where several relations are
+ * all proven empty and replaced with a single Result node. Here again, while
+ * the Result node may be joined to other things and we can speak about its
+ * place within the larger join order, we can't speak about a join ordering
+ * within the Result node itself.
+ */
+typedef enum
+{
+ JSTRAT_CLUMP_DEGENERATE = 0,
+ JSTRAT_CLUMP_FOREIGN,
+ JSTRAT_CLUMP_PARTITIONWISE
+ /* update NUM_PGPA_CLUMP_JOIN_STRATEGY if you add anything here */
+} pgpa_scan_strategy;
+
+#define NUM_PGPA_SCAN_STRATEGY ((int) JSTRAT_CLUMP_PARTITIONWISE + 1)
+
+/*
+ * All of the details we need regarding a scan.
+ */
+typedef struct pgpa_scan
+{
+ Plan *plan;
+ pgpa_scan_strategy strategy;
+ Bitmapset *relids;
+} pgpa_scan;
+
+extern pgpa_scan *pgpa_build_scan(PlannedStmt *pstmt, Plan *plan,
+ ElidedNode *elided_node);
+
+#endif
diff --git a/src/tools/pgindent/typedefs.list b/src/tools/pgindent/typedefs.list
index f8622e276c..2e2ee9aa98 100644
--- a/src/tools/pgindent/typedefs.list
+++ b/src/tools/pgindent/typedefs.list
@@ -4311,17 +4311,17 @@ ExplainOptionHandler
overexplain_options
SubPlanRTInfo
ElidedNode
+pgpa_collected_advice
pgpa_join_class
-pgpa_join_clump_strategy
pgpa_join_member
pgpa_join_strategy
-pgpa_clumped_join
-pgpa_unrolled_join
pgpa_join_unroller
-pgpa_plan_walker_context
-pgpa_output_context
-pgpa_collected_advice
-pgpa_local_advice_chunk
pgpa_local_advice
-pgpa_shared_advice_chunk
+pgpa_local_advice_chunk
+pgpa_output_context
+pgpa_plan_walker_context
+pgpa_scan
+pgpa_scan_strategy
pgpa_shared_advice
+pgpa_shared_advice_chunk
+pgpa_unrolled_join