mirror of https://github.com/citusdata/citus.git
Merge pull request #610 from citusdata/501_single_worker_queries
Refactor multi_planner to create router plan directlypull/615/head
commit
aa94a0b1ca
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue