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)
|
CreatePhysicalPlan(Query *parse)
|
||||||
{
|
{
|
||||||
Query *parseCopy = copyObject(parse);
|
Query *parseCopy = copyObject(parse);
|
||||||
MultiPlan *physicalPlan = NULL;
|
MultiPlan *physicalPlan = MultiRouterPlanCreate(parseCopy, TaskExecutorType);
|
||||||
bool routerPlannable = MultiRouterPlannableQuery(parseCopy, TaskExecutorType);
|
if (physicalPlan == NULL)
|
||||||
if (routerPlannable)
|
|
||||||
{
|
|
||||||
ereport(DEBUG2, (errmsg("Creating router plan")));
|
|
||||||
physicalPlan = MultiRouterPlanCreate(parseCopy);
|
|
||||||
CheckNodeIsDumpable((Node *) physicalPlan);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* Create and optimize logical plan */
|
/* Create and optimize logical plan */
|
||||||
MultiTreeRoot *logicalPlan = MultiLogicalPlanCreate(parseCopy);
|
MultiTreeRoot *logicalPlan = MultiLogicalPlanCreate(parseCopy);
|
||||||
|
|
|
@ -70,19 +70,20 @@ static Oid ExtractFirstDistributedTableId(Query *query);
|
||||||
static Const * ExtractInsertPartitionValue(Query *query, Var *partitionColumn);
|
static Const * ExtractInsertPartitionValue(Query *query, Var *partitionColumn);
|
||||||
static Task * RouterSelectTask(Query *query);
|
static Task * RouterSelectTask(Query *query);
|
||||||
static Job * RouterQueryJob(Query *query, Task *task);
|
static Job * RouterQueryJob(Query *query, Task *task);
|
||||||
|
static bool MultiRouterPlannableQuery(Query *query, MultiExecutorType taskExecutorType);
|
||||||
static bool ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column);
|
static bool ColumnMatchExpressionAtTopLevelConjunction(Node *node, Var *column);
|
||||||
static void SetRangeTablesInherited(Query *query);
|
static void SetRangeTablesInherited(Query *query);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MultiRouterPlanCreate creates a physical plan for given router plannable query.
|
* MultiRouterPlanCreate creates a physical plan for given query. The created plan is
|
||||||
* Created plan is either a modify task that changes a single shard, or a router task
|
* either a modify task that changes a single shard, or a router task that returns
|
||||||
* that returns query results from a single shard. Supported modify queries
|
* query results from a single shard. Supported modify queries (insert/update/delete)
|
||||||
* (insert/update/delete) are router plannble by default. The caller is expected to call
|
* are router plannable by default. If query is not router plannable then the function
|
||||||
* MultiRouterPlannableQuery to see if the query is router plannable for select queries.
|
* returns NULL.
|
||||||
*/
|
*/
|
||||||
MultiPlan *
|
MultiPlan *
|
||||||
MultiRouterPlanCreate(Query *query)
|
MultiRouterPlanCreate(Query *query, MultiExecutorType taskExecutorType)
|
||||||
{
|
{
|
||||||
Task *task = NULL;
|
Task *task = NULL;
|
||||||
Job *job = NULL;
|
Job *job = NULL;
|
||||||
|
@ -90,6 +91,14 @@ MultiRouterPlanCreate(Query *query)
|
||||||
CmdType commandType = query->commandType;
|
CmdType commandType = query->commandType;
|
||||||
bool modifyTask = false;
|
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 ||
|
if (commandType == CMD_INSERT || commandType == CMD_UPDATE ||
|
||||||
commandType == CMD_DELETE)
|
commandType == CMD_DELETE)
|
||||||
{
|
{
|
||||||
|
|
|
@ -30,8 +30,8 @@
|
||||||
#define UPSERT_ALIAS "citus_table_alias"
|
#define UPSERT_ALIAS "citus_table_alias"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern MultiPlan * MultiRouterPlanCreate(Query *query);
|
extern MultiPlan * MultiRouterPlanCreate(Query *query,
|
||||||
|
MultiExecutorType taskExecutorType);
|
||||||
extern void ErrorIfModifyQueryNotSupported(Query *queryTree);
|
extern void ErrorIfModifyQueryNotSupported(Query *queryTree);
|
||||||
extern bool MultiRouterPlannableQuery(Query *query, MultiExecutorType taskExecutorType);
|
|
||||||
|
|
||||||
#endif /* MULTI_ROUTER_PLANNER_H */
|
#endif /* MULTI_ROUTER_PLANNER_H */
|
||||||
|
|
Loading…
Reference in New Issue