reindent pathbased planner

moonshot/custom-path
Nils Dijk 2021-11-22 16:23:32 +01:00
parent 51d498e2c2
commit 0341d9fe80
No known key found for this signature in database
GPG Key ID: CA1177EF9434F241
1 changed files with 49 additions and 33 deletions

View File

@ -1,4 +1,5 @@
/* */ /* */
/* Created by Nils Dijk on 17/01/2020. */ /* Created by Nils Dijk on 17/01/2020. */
/* */ /* */
#include "postgres.h" #include "postgres.h"
@ -113,6 +114,7 @@ bool EnableBroadcastJoin = true;
static optimizeFn joinOptimizations[] = { static optimizeFn joinOptimizations[] = {
OptimizeJoinPath, OptimizeJoinPath,
OptimizeRepartitionInnerJoinPath, OptimizeRepartitionInnerJoinPath,
/* BroadcastOuterJoinPath, */ /* BroadcastOuterJoinPath, */
/* BroadcastInnerJoinPath, */ /* BroadcastInnerJoinPath, */
/* GeoOverlapJoin, */ /* GeoOverlapJoin, */
@ -171,7 +173,8 @@ typedef struct TransformVarToParamExternMutatorContext
static Node * static Node *
TransformVarToParamExternMutator(Node *node, TransformVarToParamExternMutatorContext *context) TransformVarToParamExternMutator(Node *node,
TransformVarToParamExternMutatorContext *context)
{ {
if (node == NULL) if (node == NULL)
{ {
@ -189,6 +192,7 @@ TransformVarToParamExternMutator(Node *node, TransformVarToParamExternMutatorCon
originalVarNo = var->varno; originalVarNo = var->varno;
} }
Assert(originalVarNo > 0); Assert(originalVarNo > 0);
/* If not to be replaced, we can just return the Var unmodified */ /* If not to be replaced, we can just return the Var unmodified */
if (!bms_is_member(originalVarNo, context->root->curOuterRels)) if (!bms_is_member(originalVarNo, context->root->curOuterRels))
{ {
@ -214,7 +218,6 @@ TransformVarToParamExternMutator(Node *node, TransformVarToParamExternMutatorCon
} }
else if (IsA(node, Query)) else if (IsA(node, Query))
{ {
return (Node *) query_tree_mutator((Query *) node, return (Node *) query_tree_mutator((Query *) node,
TransformVarToParamExternMutator, TransformVarToParamExternMutator,
(void *) context, (void *) context,
@ -254,7 +257,8 @@ CreateDistributedUnionPlan(PlannerInfo *root,
ShardInterval *shardInterval = NULL; ShardInterval *shardInterval = NULL;
Index *varnoMapping = NULL; /* store mapping back for outerrel checks */ Index *varnoMapping = NULL; /* store mapping back for outerrel checks */
Query *q = GetQueryFromPath(root, distUnion->worker_path, tlist, clauses, &varnoMapping); Query *q = GetQueryFromPath(root, distUnion->worker_path, tlist, clauses,
&varnoMapping);
/* /*
* Assume shards are colocated, any shard should suffice for now to find the initial * Assume shards are colocated, any shard should suffice for now to find the initial
@ -336,8 +340,8 @@ CreateDistributedUnionPlan(PlannerInfo *root,
/* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */ /* Reduce RestrictInfo list to bare expressions; ignore pseudoconstants */
clauses = extract_actual_clauses(clauses, false); clauses = extract_actual_clauses(clauses, false);
// plan->scan.plan.qual = clauses; /* plan->scan.plan.qual = clauses; */
// plan->custom_exprs = clauses; /* plan->custom_exprs = clauses; */
return (Plan *) plan; return (Plan *) plan;
} }
@ -806,11 +810,11 @@ typedef struct GeoJoinPathMatch
{ {
Const *stdwithinDistanceConst; Const *stdwithinDistanceConst;
// AggPath *innerGrouping; /* AggPath *innerGrouping; */
DistributedUnionPath *innerDistUnion; DistributedUnionPath *innerDistUnion;
GeoScanPath *innerPath; GeoScanPath *innerPath;
// AggPath *outerGrouping; /* AggPath *outerGrouping; */
DistributedUnionPath *outerDistUnion; DistributedUnionPath *outerDistUnion;
GeoScanPath *outerPath; GeoScanPath *outerPath;
} GeoJoinPathMatch; } GeoJoinPathMatch;
@ -835,6 +839,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
MatchJoin( MatchJoin(
NoCapture, NoCapture,
JOIN_INNER, JOIN_INNER,
/* match on join restriction info */ /* match on join restriction info */
MatchJoinRestrictions( MatchJoinRestrictions(
NoCapture, NoCapture,
@ -849,6 +854,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
MatchConst( MatchConst(
&match.stdwithinDistanceConst, &match.stdwithinDistanceConst,
MatchFields(consttype == FLOAT8OID))))), MatchFields(consttype == FLOAT8OID))))),
/* match inner path in join */ /* match inner path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
@ -858,6 +864,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
&match.innerDistUnion, &match.innerDistUnion,
MatchGeoScan( MatchGeoScan(
&match.innerPath)))), &match.innerPath)))),
/* match outer path in join */ /* match outer path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
@ -877,6 +884,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
MatchJoin( MatchJoin(
NoCapture, NoCapture,
JOIN_INNER, JOIN_INNER,
/* match on join restriction info */ /* match on join restriction info */
MatchJoinRestrictions( MatchJoinRestrictions(
NoCapture, NoCapture,
@ -891,6 +899,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
MatchConst( MatchConst(
&match.stdwithinDistanceConst, &match.stdwithinDistanceConst,
MatchFields(consttype == FLOAT8OID))))), MatchFields(consttype == FLOAT8OID))))),
/* match inner path in join */ /* match inner path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
@ -898,6 +907,7 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
&match.innerDistUnion, &match.innerDistUnion,
MatchGeoScan( MatchGeoScan(
&match.innerPath))), &match.innerPath))),
/* match outer path in join */ /* match outer path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
@ -922,17 +932,17 @@ GeoOverlapJoin(PlannerInfo *root, Path *originalPath)
jpath->innerjoinpath = (Path *) match.innerPath; jpath->innerjoinpath = (Path *) match.innerPath;
jpath->outerjoinpath = (Path *) match.outerPath; jpath->outerjoinpath = (Path *) match.outerPath;
// (Path *) create_append_path( /* (Path *) create_append_path( */
// root, /* root, */
// match.outerPath->custom_path.path.parent, /* match.outerPath->custom_path.path.parent, */
// list_make1(match.outerPath), /* TODO add the result of the shuffled job */ /* list_make1(match.outerPath), / * TODO add the result of the shuffled job * / */
// NIL, /* NIL, */
// NIL, /* NIL, */
// NULL, /* NULL, */
// 0, /* 0, */
// false, /* false, */
// NIL, /* NIL, */
// match.outerPath->custom_path.path.rows + 0); /* match.outerPath->custom_path.path.rows + 0); */
jpath->path.startup_cost -= 2000; /* remove the double dist union cost */ jpath->path.startup_cost -= 2000; /* remove the double dist union cost */
jpath->path.total_cost -= 2000; /* remove the double dist union cost */ jpath->path.total_cost -= 2000; /* remove the double dist union cost */
@ -965,14 +975,17 @@ OptimizeJoinPath(PlannerInfo *root, Path *originalPath)
MatchJoin( MatchJoin(
&jpath, &jpath,
JOIN_INNER, JOIN_INNER,
/* match on join restriction info */ /* match on join restriction info */
MatchAny, MatchAny,
/* match inner path in join */ /* match inner path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
MatchDistributedUnion( MatchDistributedUnion(
&innerDU, &innerDU,
MatchAny)), MatchAny)),
/* match outer path in join */ /* match outer path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
@ -1044,14 +1057,17 @@ OptimizeRepartitionInnerJoinPath(PlannerInfo *root, Path *originalPath)
MatchJoin( MatchJoin(
&joinPath, &joinPath,
JOIN_INNER, JOIN_INNER,
/* match on join restriction info */ /* match on join restriction info */
MatchAny, MatchAny,
/* match inner path in join */ /* match inner path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,
MatchDistributedUnion( MatchDistributedUnion(
&innerDU, &innerDU,
MatchAny)), MatchAny)),
/* match outer path in join */ /* match outer path in join */
SkipReadThrough( SkipReadThrough(
NoCapture, NoCapture,