const char **rt_identifiers;
StringInfo buf;
List *unrolled_joins[NUM_PGPA_JOIN_STRATEGY];
- List *clumped_joins[NUM_PGPA_CLUMP_JOIN_STRATEGY];
+ List *scans[NUM_PGPA_CLUMP_JOIN_STRATEGY];
List *query_features[NUM_PGPA_QF_TYPES];
int wrap_column;
} pgpa_output_context;
context.wrap_column = 79; /* XXX */
/*
- * Put all the top-level clumped joins for each strategy into a single
- * list.
+ * Put all the top-level scans for each strategy into a single list.
*/
- foreach(lc, walker->clumped_joins)
+ foreach(lc, walker->scans)
{
- pgpa_clumped_join *cjoin = lfirst(lc);
+ pgpa_scan *scan = lfirst(lc);
- context.clumped_joins[cjoin->strategy] =
- lappend(context.clumped_joins[cjoin->strategy], cjoin->relids);
+ context.scans[scan->strategy] =
+ lappend(context.scans[scan->strategy], scan->relids);
}
/*
* which is totally different from JOIN_ORDER(a b) and JOIN_ORDER(c d).
*
* As a side effect, the calls to pgpa_output_unrolled_join() will
- * add to the context.clumped_joins[] and context.unrolled_joins[] lists,
- * which will be important for emitting join strategy advice further down.
+ * add to the context.unrolled_joins[] lists and context.scans[] lists,
+ * which will be important for emitting join and scan strategy advice
+ * further down.
*/
foreach(lc, walker->unrolled_joins)
{
}
/*
- * Emit just one piece of advice for each clumped-join strategy that is
- * used at least once in the query.
+ * Emit just one piece of advice for each scan strategy that is used at
+ * least once in the query.
*
* XXX. It's not entirely clear that emitting DEGENERATE() advice is
* useful at all, since there is no real decision to be made: you can't
char *cstrategy = pgpa_cstring_join_clump_strategy(c);
bool first = true;
- if (context.clumped_joins[c] == NIL)
+ if (context.scans[c] == NIL)
continue;
if (buf->len > 0)
appendStringInfoChar(buf, '\n');
appendStringInfo(buf, "%s(", cstrategy);
- foreach(lc, context.clumped_joins[c])
+ foreach(lc, context.scans[c])
{
Bitmapset *relids = lfirst(lc);
* then the inner members one by one, as part of JOIN_ORDER() advice.
*
* As we visit members, we add to the context->unrolled_joins[] and
- * context->clumped_joins[] lists. The former updates are done by this
- * function directly, and the latter via pgpa_output_join_member.
+ * context->scans[] lists. The former updates are done by this function
+ * directly, and the latter via pgpa_output_join_member.
*/
static void
pgpa_output_unrolled_join(pgpa_output_context *context,
/*
* Output a single member of an unrolled join as part of JOIN_ORDER() advice.
*
- * If that member happens to be a clumped join, also add it to the appropriate
- * context->clump_joins[] list.
+ * If that member happens to be a scan, also add it to the appropriate
+ * context->scans[] list.
*/
static void
pgpa_output_join_member(pgpa_output_context *context,
{
if (member->clump_join != NULL)
{
- pgpa_clumped_join *cjoin = member->clump_join;
+ pgpa_scan *scan = member->clump_join;
appendStringInfoChar(context->buf, '{');
- pgpa_output_relations(context, context->buf, cjoin->relids);
+ pgpa_output_relations(context, context->buf, scan->relids);
appendStringInfoChar(context->buf, '}');
- context->clumped_joins[cjoin->strategy] =
- lappend(context->clumped_joins[cjoin->strategy], cjoin->relids);
+ context->scans[scan->strategy] =
+ lappend(context->scans[scan->strategy], scan->relids);
}
else if (member->unrolled_join != NULL)
{
#include "parser/parsetree.h"
/*
- * Build a pgpa_clumped_join object for a Plan node.
+ * Build a pgpa_scan object for a Plan node.
*
* If there is at least one ElidedNode for this plan node, pass the uppermost
* one as elided_node, else pass NULL.
*/
-pgpa_clumped_join *
-pgpa_build_clumped_join(PlannedStmt *pstmt, Plan *plan,
- ElidedNode *elided_node)
+pgpa_scan *
+pgpa_build_scan(PlannedStmt *pstmt, Plan *plan, ElidedNode *elided_node)
{
- pgpa_clumped_join *clump = palloc(sizeof(pgpa_clumped_join));
+ pgpa_scan *scan = palloc(sizeof(pgpa_scan));
Bitmapset *relids = NULL;
int rti = -1;
- clump->plan = plan;
+ scan->plan = plan;
if (elided_node != NULL)
{
Assert(bms_membership(elided_node->relids) == BMS_MULTIPLE);
relids = elided_node->relids;
if (elided_type == T_Append || elided_type == T_MergeAppend)
- clump->strategy = JSTRAT_CLUMP_PARTITIONWISE;
+ scan->strategy = JSTRAT_CLUMP_PARTITIONWISE;
else
elog(ERROR, "unexpected elided node type");
}
relids = pgpa_relids(plan);
if (IsA(plan, Result))
- clump->strategy = JSTRAT_CLUMP_DEGENERATE;
+ scan->strategy = JSTRAT_CLUMP_DEGENERATE;
else if (IsA(plan, ForeignScan))
- clump->strategy = JSTRAT_CLUMP_FOREIGN;
+ scan->strategy = JSTRAT_CLUMP_FOREIGN;
else if (IsA(plan, Append))
- clump->strategy = JSTRAT_CLUMP_PARTITIONWISE;
+ scan->strategy = JSTRAT_CLUMP_PARTITIONWISE;
else if (IsA(plan, MergeAppend))
- clump->strategy = JSTRAT_CLUMP_PARTITIONWISE;
+ scan->strategy = JSTRAT_CLUMP_PARTITIONWISE;
else
elog(ERROR, "unexpected plan type");
}
* and don't want them creating confusion later. (We always refer to
* groups of relations in terms of the relation RTIs, not the join RTIs.)
*/
- clump->relids = NULL;
+ scan->relids = NULL;
while ((rti = bms_next_member(relids, rti)) >= 0)
{
RangeTblEntry *rte = rt_fetch(rti, pstmt->rtable);
if (rte->rtekind != RTE_JOIN)
- clump->relids = bms_add_member(clump->relids, rti);
+ scan->relids = bms_add_member(scan->relids, rti);
}
/*
* multiple RTIs -- and even after removing the join RTIs, that should
* still be the case.
*/
- Assert(bms_membership(clump->relids) == BMS_MULTIPLE);
+ Assert(bms_membership(scan->relids) == BMS_MULTIPLE);
- return clump;
+ return scan;
}
{
if (bms_membership(n->relids) == BMS_MULTIPLE)
{
- pgpa_clumped_join *cjoin;
+ pgpa_scan *scan;
- cjoin = pgpa_build_clumped_join(walker->pstmt, plan, n);
- walker->clumped_joins = lappend(walker->clumped_joins, cjoin);
+ scan = pgpa_build_scan(walker->pstmt, plan, n);
+ walker->scans = lappend(walker->scans, scan);
}
}
*/
if (class == PGPA_CLUMPED_JOIN && join_unroll_level == 0)
{
- pgpa_clumped_join *cjoin;
+ pgpa_scan *scan;
- cjoin = pgpa_build_clumped_join(walker->pstmt, plan, NULL);
- walker->clumped_joins = lappend(walker->clumped_joins, cjoin);
+ scan = pgpa_build_scan(walker->pstmt, plan, NULL);
+ walker->scans = lappend(walker->scans, scan);
}
/*