mirror of https://github.com/citusdata/citus.git
Distinguish GetFastPathCachedPlan and GetLocalShardQueryForCache
We do this because we do not want to expose FastPathPlanCache to the local executor as much as possibleremote_prepared_txes
parent
91530ebe30
commit
bafd0c00f6
|
@ -274,7 +274,7 @@ ExecuteLocalTaskListExtended(List *taskList,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlannedStmt *planCache = GetFastPathLocalPlan(task, distributedPlan);
|
PlannedStmt *planCache = GetCachedFastPathLocalPlan(task, distributedPlan);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the plan is already cached, don't need to re-plan, just
|
* If the plan is already cached, don't need to re-plan, just
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
|
|
||||||
|
|
||||||
|
static FastPathPlanCache * GetFastPathCachedPlan(Task *task,
|
||||||
|
DistributedPlan *distributedPlan);
|
||||||
static Query * GetLocalShardQueryForCache(Query *jobQuery, Task *task,
|
static Query * GetLocalShardQueryForCache(Query *jobQuery, Task *task,
|
||||||
ParamListInfo paramListInfo);
|
ParamListInfo paramListInfo);
|
||||||
static char * DeparseLocalShardQuery(Query *jobQuery, List *relationShardList,
|
static char * DeparseLocalShardQuery(Query *jobQuery, List *relationShardList,
|
||||||
|
@ -40,7 +42,7 @@ void
|
||||||
CacheFastPathPlanForShardQuery(Task *task, DistributedPlan *originalDistributedPlan,
|
CacheFastPathPlanForShardQuery(Task *task, DistributedPlan *originalDistributedPlan,
|
||||||
ParamListInfo paramListInfo)
|
ParamListInfo paramListInfo)
|
||||||
{
|
{
|
||||||
PlannedStmt *planCache = GetFastPathLocalPlan(task, originalDistributedPlan);
|
FastPathPlanCache *planCache = GetFastPathCachedPlan(task, originalDistributedPlan);
|
||||||
if (planCache != NULL)
|
if (planCache != NULL)
|
||||||
{
|
{
|
||||||
/* we already have a local plan */
|
/* we already have a local plan */
|
||||||
|
@ -88,8 +90,8 @@ CacheFastPathPlanForShardQuery(Task *task, DistributedPlan *originalDistributedP
|
||||||
LockRelationOid(rangeTableEntry->relid, lockMode);
|
LockRelationOid(rangeTableEntry->relid, lockMode);
|
||||||
|
|
||||||
FastPathPlanCache *fastPathPlanCache = CitusMakeNode(FastPathPlanCache);
|
FastPathPlanCache *fastPathPlanCache = CitusMakeNode(FastPathPlanCache);
|
||||||
planCache = planner(localShardQuery, NULL, 0, NULL);
|
PlannedStmt *localPlan = planner(localShardQuery, NULL, 0, NULL);
|
||||||
fastPathPlanCache->localPlan = planCache;
|
fastPathPlanCache->localPlan = localPlan;
|
||||||
fastPathPlanCache->shardId = task->anchorShardId;
|
fastPathPlanCache->shardId = task->anchorShardId;
|
||||||
fastPathPlanCache->placementGroupIds = TaskGroupIdAccesses(task);
|
fastPathPlanCache->placementGroupIds = TaskGroupIdAccesses(task);
|
||||||
|
|
||||||
|
@ -226,13 +228,33 @@ ExtractParameterTypesForParamListInfo(ParamListInfo originalParamListInfo,
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GetCachedLocalPlan is a helper function which return the cached
|
* GetCachedFastPathLocalPlan is a helper function which return the cached
|
||||||
* plan in the distributedPlan for the given task if exists.
|
* plan in the distributedPlan for the given task if exists.
|
||||||
*
|
*
|
||||||
* Otherwise, the function returns NULL.
|
* Otherwise, the function returns NULL.
|
||||||
*/
|
*/
|
||||||
PlannedStmt *
|
PlannedStmt *
|
||||||
GetFastPathLocalPlan(Task *task, DistributedPlan *distributedPlan)
|
GetCachedFastPathLocalPlan(Task *task, DistributedPlan *distributedPlan)
|
||||||
|
{
|
||||||
|
FastPathPlanCache *fastPathPlanCache = GetFastPathCachedPlan(task, distributedPlan);
|
||||||
|
|
||||||
|
if (fastPathPlanCache != NULL)
|
||||||
|
{
|
||||||
|
return fastPathPlanCache->localPlan;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GetFastPathCachedPlan is a helper function which return the cached
|
||||||
|
* plan in the distributedPlan for the given task if exists.
|
||||||
|
*
|
||||||
|
* Otherwise, the function returns NULL.
|
||||||
|
*/
|
||||||
|
static FastPathPlanCache *
|
||||||
|
GetFastPathCachedPlan(Task *task, DistributedPlan *distributedPlan)
|
||||||
{
|
{
|
||||||
if (distributedPlan == NULL || distributedPlan->workerJob == NULL)
|
if (distributedPlan == NULL || distributedPlan->workerJob == NULL)
|
||||||
{
|
{
|
||||||
|
@ -250,7 +272,7 @@ GetFastPathLocalPlan(Task *task, DistributedPlan *distributedPlan)
|
||||||
fastPathPlanCache->placementGroupIds) == NIL)
|
fastPathPlanCache->placementGroupIds) == NIL)
|
||||||
{
|
{
|
||||||
/* already have a cached plan, no need to continue */
|
/* already have a cached plan, no need to continue */
|
||||||
return fastPathPlanCache->localPlan;
|
return fastPathPlanCache;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
extern bool IsFastPathPlanCachingSupported(Job *currentJob,
|
extern bool IsFastPathPlanCachingSupported(Job *currentJob,
|
||||||
DistributedPlan *originalDistributedPlan);
|
DistributedPlan *originalDistributedPlan);
|
||||||
extern PlannedStmt * GetFastPathLocalPlan(Task *task, DistributedPlan *distributedPlan);
|
extern PlannedStmt * GetCachedFastPathLocalPlan(Task *task,
|
||||||
|
DistributedPlan *distributedPlan);
|
||||||
extern void CacheFastPathPlanForShardQuery(Task *task,
|
extern void CacheFastPathPlanForShardQuery(Task *task,
|
||||||
DistributedPlan *originalDistributedPlan,
|
DistributedPlan *originalDistributedPlan,
|
||||||
ParamListInfo paramListInfo);
|
ParamListInfo paramListInfo);
|
||||||
|
|
Loading…
Reference in New Issue