mirror of https://github.com/citusdata/citus.git
Reduce calls to FastPathRouterQuery()
Before this commit, we called it twice durning planning. Instead, we save the information and pass it.pull/3332/head
parent
270571c106
commit
ca293116fa
|
@ -128,6 +128,7 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
||||||
bool setPartitionedTablesInherited = false;
|
bool setPartitionedTablesInherited = false;
|
||||||
List *rangeTableList = ExtractRangeTableEntryList(parse);
|
List *rangeTableList = ExtractRangeTableEntryList(parse);
|
||||||
int rteIdCounter = 1;
|
int rteIdCounter = 1;
|
||||||
|
bool fastPathRouterQuery = false;
|
||||||
|
|
||||||
if (cursorOptions & CURSOR_OPT_FORCE_DISTRIBUTED)
|
if (cursorOptions & CURSOR_OPT_FORCE_DISTRIBUTED)
|
||||||
{
|
{
|
||||||
|
@ -151,6 +152,10 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
needsDistributedPlanning = ListContainsDistributedTableRTE(rangeTableList);
|
needsDistributedPlanning = ListContainsDistributedTableRTE(rangeTableList);
|
||||||
|
if (needsDistributedPlanning)
|
||||||
|
{
|
||||||
|
fastPathRouterQuery = FastPathRouterQuery(parse);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,8 +220,11 @@ distributed_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
|
||||||
* transformations made by postgres' planner.
|
* transformations made by postgres' planner.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (needsDistributedPlanning && FastPathRouterQuery(originalQuery))
|
if (needsDistributedPlanning && fastPathRouterQuery)
|
||||||
{
|
{
|
||||||
|
plannerRestrictionContext->fastPathRestrictionContext->fastPathRouterQuery =
|
||||||
|
true;
|
||||||
|
|
||||||
result = FastPathPlanner(originalQuery, parse, boundParams);
|
result = FastPathPlanner(originalQuery, parse, boundParams);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1870,6 +1878,9 @@ CreateAndPushPlannerRestrictionContext(void)
|
||||||
plannerRestrictionContext->joinRestrictionContext =
|
plannerRestrictionContext->joinRestrictionContext =
|
||||||
palloc0(sizeof(JoinRestrictionContext));
|
palloc0(sizeof(JoinRestrictionContext));
|
||||||
|
|
||||||
|
plannerRestrictionContext->fastPathRestrictionContext =
|
||||||
|
palloc0(sizeof(FastPathRestrictionContext));
|
||||||
|
|
||||||
plannerRestrictionContext->memoryContext = CurrentMemoryContext;
|
plannerRestrictionContext->memoryContext = CurrentMemoryContext;
|
||||||
|
|
||||||
/* we'll apply logical AND as we add tables */
|
/* we'll apply logical AND as we add tables */
|
||||||
|
@ -1929,6 +1940,10 @@ ResetPlannerRestrictionContext(PlannerRestrictionContext *plannerRestrictionCont
|
||||||
plannerRestrictionContext->joinRestrictionContext =
|
plannerRestrictionContext->joinRestrictionContext =
|
||||||
palloc0(sizeof(JoinRestrictionContext));
|
palloc0(sizeof(JoinRestrictionContext));
|
||||||
|
|
||||||
|
plannerRestrictionContext->fastPathRestrictionContext =
|
||||||
|
palloc0(sizeof(FastPathRestrictionContext));
|
||||||
|
|
||||||
|
|
||||||
/* we'll apply logical AND as we add tables */
|
/* we'll apply logical AND as we add tables */
|
||||||
plannerRestrictionContext->relationRestrictionContext->allReferenceTables = true;
|
plannerRestrictionContext->relationRestrictionContext->allReferenceTables = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,6 +441,9 @@ RouterModifyTaskForShardInterval(Query *originalQuery, ShardInterval *shardInter
|
||||||
plannerRestrictionContext->relationRestrictionContext);
|
plannerRestrictionContext->relationRestrictionContext);
|
||||||
copyOfPlannerRestrictionContext->joinRestrictionContext =
|
copyOfPlannerRestrictionContext->joinRestrictionContext =
|
||||||
plannerRestrictionContext->joinRestrictionContext;
|
plannerRestrictionContext->joinRestrictionContext;
|
||||||
|
copyOfPlannerRestrictionContext->fastPathRestrictionContext =
|
||||||
|
plannerRestrictionContext->fastPathRestrictionContext;
|
||||||
|
|
||||||
relationRestrictionList =
|
relationRestrictionList =
|
||||||
copyOfPlannerRestrictionContext->relationRestrictionContext->
|
copyOfPlannerRestrictionContext->relationRestrictionContext->
|
||||||
relationRestrictionList;
|
relationRestrictionList;
|
||||||
|
|
|
@ -2014,6 +2014,8 @@ PlanRouterQuery(Query *originalQuery,
|
||||||
bool shardsPresent = false;
|
bool shardsPresent = false;
|
||||||
uint64 shardId = INVALID_SHARD_ID;
|
uint64 shardId = INVALID_SHARD_ID;
|
||||||
CmdType commandType = originalQuery->commandType;
|
CmdType commandType = originalQuery->commandType;
|
||||||
|
bool fastPathRouterQuery =
|
||||||
|
plannerRestrictionContext->fastPathRestrictionContext->fastPathRouterQuery;
|
||||||
|
|
||||||
*placementList = NIL;
|
*placementList = NIL;
|
||||||
|
|
||||||
|
@ -2022,7 +2024,7 @@ PlanRouterQuery(Query *originalQuery,
|
||||||
* not been called. Thus, restriction information is not avaliable and we do the
|
* not been called. Thus, restriction information is not avaliable and we do the
|
||||||
* shard pruning based on the distribution column in the quals of the query.
|
* shard pruning based on the distribution column in the quals of the query.
|
||||||
*/
|
*/
|
||||||
if (FastPathRouterQuery(originalQuery))
|
if (fastPathRouterQuery)
|
||||||
{
|
{
|
||||||
List *shardIntervalList =
|
List *shardIntervalList =
|
||||||
TargetShardIntervalForFastPathQuery(originalQuery, partitionValueConst,
|
TargetShardIntervalForFastPathQuery(originalQuery, partitionValueConst,
|
||||||
|
|
|
@ -85,10 +85,23 @@ typedef struct JoinRestriction
|
||||||
RelOptInfo *outerrel;
|
RelOptInfo *outerrel;
|
||||||
} JoinRestriction;
|
} JoinRestriction;
|
||||||
|
|
||||||
|
typedef struct FastPathRestrictionContext
|
||||||
|
{
|
||||||
|
bool fastPathRouterQuery;
|
||||||
|
}FastPathRestrictionContext;
|
||||||
|
|
||||||
typedef struct PlannerRestrictionContext
|
typedef struct PlannerRestrictionContext
|
||||||
{
|
{
|
||||||
RelationRestrictionContext *relationRestrictionContext;
|
RelationRestrictionContext *relationRestrictionContext;
|
||||||
JoinRestrictionContext *joinRestrictionContext;
|
JoinRestrictionContext *joinRestrictionContext;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* When the query is qualified for fast path, we don't have
|
||||||
|
* the RelationRestrictionContext and JoinRestrictionContext
|
||||||
|
* since those are dependent to calling standard_planner.
|
||||||
|
* Instead, we keep this struct to pass some extra information.
|
||||||
|
*/
|
||||||
|
FastPathRestrictionContext *fastPathRestrictionContext;
|
||||||
bool hasSemiJoin;
|
bool hasSemiJoin;
|
||||||
MemoryContext memoryContext;
|
MemoryContext memoryContext;
|
||||||
} PlannerRestrictionContext;
|
} PlannerRestrictionContext;
|
||||||
|
|
Loading…
Reference in New Issue