PG_MODULE_MAGIC;
-static pgpa_shared_state * pgpa_state = NULL;
+static pgpa_shared_state *pgpa_state = NULL;
static dsa_area *pgpa_dsa_area = NULL;
/* GUC variables */
LWLock lock;
int dsa_tranche;
dsa_handle area;
- dsa_pointer shared_collector;
+ dsa_pointer shared_collector;
} pgpa_shared_state;
/* GUC variables */
-extern void
-pgpa_collect_advice(uint64 queryId, const char *query_string,
- const char *advice_string);
+extern void pgpa_collect_advice(uint64 queryId, const char *query_string,
+ const char *advice_string);
elidedinner = pgpa_descend_node(pstmt, &innerplan);
/*
- * If this is a semijoin that was converted to an inner join by making
- * one side or the other unique, make a note that the inner or outer
- * subplan, as appropriate, should be treated as a query plan feature
- * when the main tree traversal reaches it.
+ * If this is a semijoin that was converted to an inner join by making one
+ * side or the other unique, make a note that the inner or outer subplan,
+ * as appropriate, should be treated as a query plan feature when the main
+ * tree traversal reaches it.
*
* Conversely, if the planner could have made one side of the join unique
- * and thereby converted it to an inner join, and chose not to do so,
- * that is also worth noting. (XXX: I'm not sure that we need to emit
+ * and thereby converted it to an inner join, and chose not to do so, that
+ * is also worth noting. (XXX: I'm not sure that we need to emit
* non-unique advice in every case where these join-type tests pass.)
*
- * NB: This code could appear slightly higher up in in this function,
- * but none of the nodes through which we just descended should be have
+ * NB: This code could appear slightly higher up in in this function, but
+ * none of the nodes through which we just descended should be have
* associated RTIs.
*
- * NB: This seems like a somewhat hacky way of passing information up
- * to the main tree walk, but I don't currently have a better idea.
+ * NB: This seems like a somewhat hacky way of passing information up to
+ * the main tree walk, but I don't currently have a better idea.
*/
if (uniqueouter)
pgpa_add_future_feature(walker, PGPAQF_SEMIJOIN_UNIQUE, outerplan);
*/
foreach(lc, walker->scans)
{
- pgpa_scan *scan = lfirst(lc);
+ pgpa_scan *scan = lfirst(lc);
context.scans[scan->strategy] =
lappend(context.scans[scan->strategy], scan->relids);
* is the driving table which is then joined to "b" then "c" then "d",
* 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.unrolled_joins[] lists and context.scans[] lists,
- * which will be important for emitting join and scan strategy advice
- * further down.
+ * As a side effect, the calls to pgpa_output_unrolled_join() will 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)
{
*/
for (int s = 0; s < NUM_PGPA_JOIN_STRATEGY; ++s)
{
- char *strategy = pgpa_cstring_join_strategy(s);
- bool first = true;
+ char *strategy = pgpa_cstring_join_strategy(s);
+ bool first = true;
if (context.unrolled_joins[s] == NIL)
continue;
foreach(lc, context.unrolled_joins[s])
{
- Bitmapset *relids = lfirst(lc);
+ Bitmapset *relids = lfirst(lc);
if (first)
first = false;
* 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
* decide whether or not something is provably empty. On the other hand,
- * it might be useful to human beings even if the computer doesn't need it.
- * FOREIGN() and PARTITIONWISE() are clearly useful, but they are scan
+ * it might be useful to human beings even if the computer doesn't need
+ * it. FOREIGN() and PARTITIONWISE() are clearly useful, but they are scan
* types as well as join types, and the question of how to handle that
* deserves more thought.
*/
for (int c = 0; c < NUM_PGPA_SCAN_STRATEGY; ++c)
{
- char *cstrategy = pgpa_cstring_scan_strategy(c);
- bool first = true;
+ char *cstrategy = pgpa_cstring_scan_strategy(c);
+ bool first = true;
if (context.scans[c] == NIL)
continue;
foreach(lc, context.scans[c])
{
- Bitmapset *relids = lfirst(lc);
+ Bitmapset *relids = lfirst(lc);
if (first)
first = false;
*/
for (int t = 0; t < NUM_PGPA_QF_TYPES; ++t)
{
- bool first = true;
+ bool first = true;
if (context.query_features[t] == NIL)
continue;
{
if (member->clump_join != NULL)
{
- pgpa_scan *scan = member->clump_join;
+ pgpa_scan *scan = member->clump_join;
appendStringInfoChar(context->buf, '{');
pgpa_output_relations(context, context->buf, scan->relids);
pgpa_scan *
pgpa_build_scan(PlannedStmt *pstmt, Plan *plan, ElidedNode *elided_node)
{
- pgpa_scan *scan = palloc(sizeof(pgpa_scan));
- Bitmapset *relids = NULL;
- int rti = -1;
+ pgpa_scan *scan = palloc(sizeof(pgpa_scan));
+ Bitmapset *relids = NULL;
+ int rti = -1;
scan->plan = plan;
* If this is a Gather or Gather Merge node, directly add it to the list
* of currently-active query features.
*
- * Otherwise, check the future_query_features list to see whether this
- * was previously identified as a plan node that needs to be treated as
- * a query feature.
+ * Otherwise, check the future_query_features list to see whether this was
+ * previously identified as a plan node that needs to be treated as a
+ * query feature.
*/
if (IsA(plan, Gather))
{
{
if (bms_membership(n->relids) == BMS_MULTIPLE)
{
- pgpa_scan *scan;
+ pgpa_scan *scan;
scan = pgpa_build_scan(walker->pstmt, plan, n);
walker->scans = lappend(walker->scans, scan);
* considered as part of the same join problem, nodes elided during
* setrefs processing act as boundaries.
*
- * In more detail, if an Append or MergeAppend was elided, then j
- * a partitionwise join was chosen and only a single child survived;
- * if a SubqueryScan was elided, the subquery was separately without
+ * In more detail, if an Append or MergeAppend was elided, then j a
+ * partitionwise join was chosen and only a single child survived; if
+ * a SubqueryScan was elided, the subquery was separately without
* 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.
*/
if (class == PGPA_CLUMPED_JOIN && join_unroll_level == 0)
{
- pgpa_scan *scan;
+ pgpa_scan *scan;
scan = pgpa_build_scan(walker->pstmt, plan, NULL);
walker->scans = lappend(walker->scans, scan);
{
case T_Append:
{
- Append *aplan = (Append *) plan;
+ Append *aplan = (Append *) plan;
extraplans = aplan->appendplans;
pushdown_query_features = bms_is_empty(aplan->apprelids);
extraplans = ((BitmapOr *) plan)->bitmapplans;
break;
case T_SubqueryScan:
+
/*
* We don't pass down active_query_features across here, because
* those are specific to a subquery level.
*/
if (is_query_feature)
{
- int num_aqf = list_length(active_query_features);
+ int num_aqf = list_length(active_query_features);
(void) list_truncate(active_query_features, num_aqf - 1);
}
pgpa_qf_add_plan_rtis(List *active_query_features, Plan *plan)
{
Bitmapset *relids;
- Index rti;
+ Index rti;
if ((relids = pgpa_relids(plan)) != NULL)
pgpa_qf_add_rtis(active_query_features, relids);
*/
typedef struct pgpa_query_feature
{
- pgpa_qf_type type;
+ pgpa_qf_type type;
Plan *plan;
Bitmapset *relids;
} pgpa_query_feature;
pgpa_local_advice_chunk
pgpa_output_context
pgpa_plan_walker_context
+pgpa_qf_type
+pgpa_query_feature
pgpa_scan
pgpa_scan_strategy
pgpa_shared_advice
pgpa_shared_advice_chunk
+pgpa_shared_state
pgpa_unrolled_join