Merge pull request #610 from citusdata/501_single_worker_queries

Refactor multi_planner to create router plan directly
pull/615/head
Murat Tuncer 2016-06-21 12:54:30 +03:00 committed by GitHub
commit aa94a0b1ca
3 changed files with 19 additions and 17 deletions

View File

@ -72,15 +72,8 @@ MultiPlan *
CreatePhysicalPlan(Query *parse)
{
Query *parseCopy = copyObject(parse);
MultiPlan *physicalPlan = NULL;
bool routerPlannable = MultiRouterPlannableQuery(parseCopy, TaskExecutorType);
if (routerPlannable)
{
ereport(DEBUG2, (errmsg("Creating router plan")));
physicalPlan = MultiRouterPlanCreate(parseCopy);
CheckNodeIsDumpable((Node *) physicalPlan);
}
else
MultiPlan *physicalPlan = MultiRouterPlanCreate(parseCopy, TaskExecutorType);
if (physicalPlan == NULL)
{
/* Create and optimize logical plan */
MultiTreeRoot *logicalPlan = MultiLogicalPlanCreate(parseCopy);

View File

@ -70,19 +70,20 @@ static Oid ExtractFirstDistributedTableId(Query *query);
static Const * ExtractInsertPartitionValue(Query *query, Var *partitionColumn);
static Task * RouterSelectTask(Query *query);
static Job * RouterQueryJob(Query *query, Task *task);
static bool MultiRouterPlannableQuery(Query *query, MultiExecutorType taskExecutorType);
static bool ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column);
static void SetRangeTablesInherited(Query *query);
/*
* MultiRouterPlanCreate creates a physical plan for given router plannable query.
* Created plan is either a modify task that changes a single shard, or a router task
* that returns query results from a single shard. Supported modify queries
* (insert/update/delete) are router plannble by default. The caller is expected to call
* MultiRouterPlannableQuery to see if the query is router plannable for select queries.
* MultiRouterPlanCreate creates a physical plan for given query. The created plan is
* either a modify task that changes a single shard, or a router task that returns
* query results from a single shard. Supported modify queries (insert/update/delete)
* are router plannable by default. If query is not router plannable then the function
* returns NULL.
*/
MultiPlan *
MultiRouterPlanCreate(Query *query)
MultiRouterPlanCreate(Query *query, MultiExecutorType taskExecutorType)
{
Task *task = NULL;
Job *job = NULL;
@ -90,6 +91,14 @@ MultiRouterPlanCreate(Query *query)
CmdType commandType = query->commandType;
bool modifyTask = false;
bool routerPlannable = MultiRouterPlannableQuery(query, taskExecutorType);
if (!routerPlannable)
{
return NULL;
}
ereport(DEBUG2, (errmsg("Creating router plan")));
if (commandType == CMD_INSERT || commandType == CMD_UPDATE ||
commandType == CMD_DELETE)
{

View File

@ -30,8 +30,8 @@
#define UPSERT_ALIAS "citus_table_alias"
#endif
extern MultiPlan * MultiRouterPlanCreate(Query *query);
extern MultiPlan * MultiRouterPlanCreate(Query *query,
MultiExecutorType taskExecutorType);
extern void ErrorIfModifyQueryNotSupported(Query *queryTree);
extern bool MultiRouterPlannableQuery(Query *query, MultiExecutorType taskExecutorType);
#endif /* MULTI_ROUTER_PLANNER_H */