Add back partition column equality check

pull/1175/head
Onder Kalaci 2017-01-30 13:41:45 +02:00
parent 20e1f36fb9
commit 2460e47683
3 changed files with 234 additions and 86 deletions

View File

@ -78,6 +78,12 @@ typedef struct InstantiateQualWalker
Var *relationPartitionColumn; Var *relationPartitionColumn;
}InstantiateQualWalker; }InstantiateQualWalker;
typedef struct PartitionColumnEqualityCheckWalker
{
Query *subquery;
bool partitionColumnEqualityExists;
}PartitionColumnEqualityCheckWalker;
bool EnableRouterExecution = true; bool EnableRouterExecution = true;
@ -135,6 +141,7 @@ static DeferredErrorMessage * InsertPartitionColumnMatchesSelect(Query *query,
Oid * Oid *
selectPartitionColumnTableId); selectPartitionColumnTableId);
static void AddUninstantiatedEqualityQual(Query *query, Var *targetPartitionColumnVar); static void AddUninstantiatedEqualityQual(Query *query, Var *targetPartitionColumnVar);
static bool PartitionColumnEqualityWalker(Node *inputNode, void *context);
static DeferredErrorMessage * ErrorIfQueryHasModifyingCTE(Query *queryTree); static DeferredErrorMessage * ErrorIfQueryHasModifyingCTE(Query *queryTree);
@ -475,8 +482,7 @@ RouterModifyTaskForShardInterval(Query *originalQuery, ShardInterval *shardInter
/* /*
* It doesn't make sense that the anchor shard interval and target shard interval * It doesn't make sense that the anchor shard interval and target shard interval
* have different ranges. This case is valid once original query already * have different ranges. This case is valid once original query already
* includes a partition column equality qual and there is a JOIN on the * includes a partition column equality qual.
* same column.
* *
* We actually could skip adding this check here since the subquery would return zero * We actually could skip adding this check here since the subquery would return zero
* rows given that we already have AddShardIntervalRestrictionToSelect(). However, by * rows given that we already have AddShardIntervalRestrictionToSelect(). However, by
@ -534,7 +540,7 @@ RouterModifyTaskForShardInterval(Query *originalQuery, ShardInterval *shardInter
modifyTask = CreateBasicTask(jobId, taskIdIndex, MODIFY_TASK, queryString->data); modifyTask = CreateBasicTask(jobId, taskIdIndex, MODIFY_TASK, queryString->data);
modifyTask->dependedTaskList = NULL; modifyTask->dependedTaskList = NULL;
modifyTask->anchorShardId = shardId; modifyTask->anchorShardId = shardId;
modifyTask->taskPlacementList = FinalizedShardPlacementList(shardId); modifyTask->taskPlacementList = insertShardPlacementList;
modifyTask->upsertQuery = upsertQuery; modifyTask->upsertQuery = upsertQuery;
modifyTask->relationShardList = relationShardList; modifyTask->relationShardList = relationShardList;
modifyTask->replicationModel = cacheEntry->replicationModel; modifyTask->replicationModel = cacheEntry->replicationModel;
@ -1197,6 +1203,22 @@ AddUninstantiatedEqualityQual(Query *query, Var *partitionColumn)
Oid equalsOperator = InvalidOid; Oid equalsOperator = InvalidOid;
Oid greaterOperator = InvalidOid; Oid greaterOperator = InvalidOid;
bool hashable = false; bool hashable = false;
PartitionColumnEqualityCheckWalker *walker =
palloc0(sizeof(PartitionColumnEqualityCheckWalker));
AssertArg(query->commandType == CMD_SELECT);
walker->partitionColumnEqualityExists = false;
walker->subquery = query;
/* if the query already includes part_column = const, we don't need to add another */
PartitionColumnEqualityWalker((Node *) query->jointree->quals, walker);
if (walker->partitionColumnEqualityExists)
{
ereport(DEBUG2, (errmsg("skipping to add uninstantiated equality qual")));
return;
}
/* get the necessary equality operator */ /* get the necessary equality operator */
get_sort_group_operators(partitionColumn->vartype, false, true, false, get_sort_group_operators(partitionColumn->vartype, false, true, false,
@ -1239,6 +1261,53 @@ AddUninstantiatedEqualityQual(Query *query, Var *partitionColumn)
} }
/*
* PartitionColumnEqualityWalker walks over the quals of a join tree and checks
* whether the quals include any (partitionColumn = Const) expression. If so, context
* is marked accordingly and the iteration is terminated.
*/
static bool
PartitionColumnEqualityWalker(Node *inputNode, void *context)
{
PartitionColumnEqualityCheckWalker *walker =
(PartitionColumnEqualityCheckWalker *) context;
if (inputNode == NULL)
{
return false;
}
if (IsA(inputNode, OpExpr) && list_length(((OpExpr *) inputNode)->args) == 2)
{
OpExpr *op = (OpExpr *) inputNode;
Node *leftop = get_leftop((Expr *) op);
Node *rightop = get_rightop((Expr *) op);
Var *column = NULL;
if (IsA(leftop, Var) && IsA(rightop, Const) &&
OperatorImplementsEquality(op->opno))
{
column = (Var *) leftop;
}
else if (IsA(leftop, Const) && IsA(rightop, Var) &&
OperatorImplementsEquality(op->opno))
{
column = (Var *) rightop;
}
if (column && IsPartitionColumn((Expr *) column, walker->subquery))
{
walker->partitionColumnEqualityExists = true;
return true;
}
}
return expression_tree_walker(inputNode, PartitionColumnEqualityWalker,
(void *) context);
}
/* /*
* ModifyQuerySupported returns NULL if the query only contains supported * ModifyQuerySupported returns NULL if the query only contains supported
* features, otherwise it returns an error description. * features, otherwise it returns an error description.
@ -3052,7 +3121,7 @@ InstantiatePartitionQual(Node *node, void *context)
if (IsA(rightop, Var)) if (IsA(rightop, Var))
{ {
currentColumn = (Var *) rightop; currentColumn = (Var *) rightop;
} }
} }
else if (IsA(rightop, Param)) else if (IsA(rightop, Param))

View File

@ -197,25 +197,23 @@ INSERT INTO raw_events_second (user_id, time) SELECT user_id, time FROM raw_even
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300000 DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300004 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300004 since it doesn't have the same shard range with the select anchor shard interval 13300001
DEBUG: predicate pruning for shardId 13300000 DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, "time") SELECT user_id, "time" FROM public.raw_events_first_13300001 raw_events_first WHERE ((user_id = 7) AND ((hashint4(user_id) >= '-1073741824'::integer) AND (hashint4(user_id) <= '-1'::integer))) DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, "time") SELECT user_id, "time" FROM public.raw_events_first_13300001 raw_events_first WHERE ((user_id = 7) AND ((hashint4(user_id) >= '-1073741824'::integer) AND (hashint4(user_id) <= '-1'::integer)))
DEBUG: predicate pruning for shardId 13300000 DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300006 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300006 since it doesn't have the same shard range with the select anchor shard interval 13300001
DEBUG: predicate pruning for shardId 13300000 DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300007 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300007 since it doesn't have the same shard range with the select anchor shard interval 13300001
DEBUG: ProcessQuery DEBUG: ProcessQuery
DEBUG: Plan is router executable DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
@ -244,25 +242,23 @@ WHERE
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300004 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300000 raw_events_first WHERE ((user_id = 8) AND ((hashint4(user_id) >= '-2147483648'::integer) AND (hashint4(user_id) <= '-1073741825'::integer))) DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300004 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_first_13300000 raw_events_first WHERE ((user_id = 8) AND ((hashint4(user_id) >= '-2147483648'::integer) AND (hashint4(user_id) <= '-1073741825'::integer)))
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300005 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300005 since it doesn't have the same shard range with the select anchor shard interval 13300000
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300006 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300006 since it doesn't have the same shard range with the select anchor shard interval 13300000
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300007 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300007 since it doesn't have the same shard range with the select anchor shard interval 13300000
DEBUG: ProcessQuery DEBUG: ProcessQuery
DEBUG: Plan is router executable DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
@ -370,29 +366,11 @@ RETURNING *;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: predicate pruning for shardId 13300000 DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300004 since SELECT query for it pruned away
DEBUG: predicate pruning for shardId 13300000 DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 ERROR: cannot perform distributed planning for the given modification
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300005 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300001 raw_events_first WHERE (((user_id = 9) OR (user_id = 16)) AND ((hashint4(user_id) >= '-1073741824'::integer) AND (hashint4(user_id) <= '-1'::integer))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4 DETAIL: Select query cannot be pushed down to the worker.
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
DEBUG: Skipping target shard interval 13300006 since SELECT query for it pruned away
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: distributed statement: INSERT INTO public.raw_events_second_13300007 AS citus_table_alias (user_id, value_1, value_3) SELECT user_id, value_1, value_3 FROM public.raw_events_first_13300003 raw_events_first WHERE (((user_id = 9) OR (user_id = 16)) AND ((hashint4(user_id) >= 1073741824) AND (hashint4(user_id) <= 2147483647))) RETURNING citus_table_alias.user_id, citus_table_alias."time", citus_table_alias.value_1, citus_table_alias.value_2, citus_table_alias.value_3, citus_table_alias.value_4
DEBUG: ProcessQuery
DEBUG: Plan is router executable
ERROR: duplicate key value violates unique constraint "raw_events_second_user_id_value_1_key_13300007"
DETAIL: Key (user_id, value_1)=(9, 90) already exists.
CONTEXT: while executing command on localhost:57638
-- now do some aggregations -- now do some aggregations
INSERT INTO agg_events INSERT INTO agg_events
SELECT SELECT
@ -1226,6 +1204,7 @@ FROM
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
@ -1236,7 +1215,6 @@ DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_t
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1244,7 +1222,6 @@ DEBUG: Skipping target shard interval 13300009 since it doesn't have the same s
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1252,7 +1229,6 @@ DEBUG: Skipping target shard interval 13300010 since it doesn't have the same s
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1271,6 +1247,7 @@ FROM
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
@ -1313,6 +1290,7 @@ FROM
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: Skipping target shard interval 13300008 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300008 since SELECT query for it pruned away
DEBUG: Skipping target shard interval 13300009 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300009 since SELECT query for it pruned away
DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300010 since SELECT query for it pruned away
@ -1331,6 +1309,7 @@ FROM
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
NOTICE: cannot use shard pruning with ANY/ALL (array expression) NOTICE: cannot use shard pruning with ANY/ALL (array expression)
HINT: Consider rewriting the expression with OR/AND clauses. HINT: Consider rewriting the expression with OR/AND clauses.
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
@ -1345,7 +1324,6 @@ HINT: Consider rewriting the expression with OR/AND clauses.
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1355,7 +1333,6 @@ HINT: Consider rewriting the expression with OR/AND clauses.
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1365,7 +1342,6 @@ HINT: Consider rewriting the expression with OR/AND clauses.
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1384,6 +1360,7 @@ FROM
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001 DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002 DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
@ -1425,6 +1402,53 @@ DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
-- the following is a very tricky query for Citus
-- although we do not support pushing down JOINs on non-partition
-- columns here it is safe to push it down given that we're looking for
-- a specific value (i.e., value_1 = 12) on the joning column.
INSERT INTO agg_events
(user_id)
SELECT raw_events_first.user_id
FROM raw_events_first,
raw_events_second
WHERE raw_events_second.user_id = raw_events_first.value_1
AND raw_events_first.value_1 = 12;
DEBUG: StartTransactionCommand
DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: distributed statement: INSERT INTO public.agg_events_13300008 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM public.raw_events_first_13300000 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (((raw_events_second.user_id = raw_events_first.value_1) AND (raw_events_first.value_1 = 12)) AND ((hashint4(raw_events_first.user_id) >= '-2147483648'::integer) AND (hashint4(raw_events_first.user_id) <= '-1073741825'::integer)))
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: distributed statement: INSERT INTO public.agg_events_13300009 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM public.raw_events_first_13300001 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (((raw_events_second.user_id = raw_events_first.value_1) AND (raw_events_first.value_1 = 12)) AND ((hashint4(raw_events_first.user_id) >= '-1073741824'::integer) AND (hashint4(raw_events_first.user_id) <= '-1'::integer)))
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300003
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: distributed statement: INSERT INTO public.agg_events_13300010 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM public.raw_events_first_13300002 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (((raw_events_second.user_id = raw_events_first.value_1) AND (raw_events_first.value_1 = 12)) AND ((hashint4(raw_events_first.user_id) >= 0) AND (hashint4(raw_events_first.user_id) <= 1073741823)))
DEBUG: predicate pruning for shardId 13300000
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: distributed statement: INSERT INTO public.agg_events_13300011 AS citus_table_alias (user_id) SELECT raw_events_first.user_id FROM public.raw_events_first_13300003 raw_events_first, public.raw_events_second_13300007 raw_events_second WHERE (((raw_events_second.user_id = raw_events_first.value_1) AND (raw_events_first.value_1 = 12)) AND ((hashint4(raw_events_first.user_id) >= 1073741824) AND (hashint4(raw_events_first.user_id) <= 2147483647)))
DEBUG: ProcessQuery
DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand
DEBUG: CommitTransaction
DEBUG: name: unnamed; blockState: STARTED; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
-- some unsupported LEFT/INNER JOINs -- some unsupported LEFT/INNER JOINs
-- JOIN on one table with partition column other is not -- JOIN on one table with partition column other is not
INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
@ -1484,19 +1508,38 @@ ERROR: cannot perform distributed planning for the given modification
DETAIL: Select query cannot be pushed down to the worker. DETAIL: Select query cannot be pushed down to the worker.
-- JOIN on one table with partition column other is not -- JOIN on one table with partition column other is not
-- also an equality qual is added on the partition key -- also an equality qual is added on the partition key
--INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
--SELECT SELECT
-- raw_events_first.user_id raw_events_first.user_id
--FROM FROM
-- raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1 raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1
-- WHERE raw_events_first.user_id = 10; WHERE
raw_events_first.user_id = 10;
DEBUG: StartTransactionCommand
DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
ERROR: cannot perform distributed planning for the given modification
DETAIL: Select query cannot be pushed down to the worker.
-- same as the above with INNER JOIN -- same as the above with INNER JOIN
--INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
--SELECT SELECT
-- raw_events_first.user_id raw_events_first.user_id
--FROM FROM
-- raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1 raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1
-- WHERE raw_events_first.user_id = 10; WHERE raw_events_first.user_id = 10;
DEBUG: StartTransactionCommand
DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
ERROR: cannot perform distributed planning for the given modification
DETAIL: Select query cannot be pushed down to the worker.
-- make things a bit more complicate with IN clauses -- make things a bit more complicate with IN clauses
INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
SELECT SELECT
@ -1527,6 +1570,24 @@ DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003 DEBUG: predicate pruning for shardId 13300003
ERROR: cannot perform distributed planning for the given modification ERROR: cannot perform distributed planning for the given modification
DETAIL: Select query cannot be pushed down to the worker. DETAIL: Select query cannot be pushed down to the worker.
-- the following is again a very tricky query for Citus
-- if the given filter was on value_1 as shown in the above, Citus could
-- push it down. But here the query is refused
INSERT INTO agg_events
(user_id)
SELECT raw_events_first.user_id
FROM raw_events_first,
raw_events_second
WHERE raw_events_second.user_id = raw_events_first.value_1
AND raw_events_first.value_2 = 12;
DEBUG: StartTransactionCommand
DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: predicate pruning for shardId 13300001
DEBUG: predicate pruning for shardId 13300002
DEBUG: predicate pruning for shardId 13300003
ERROR: cannot perform distributed planning for the given modification
DETAIL: Select query cannot be pushed down to the worker.
-- unsupported JOIN -- unsupported JOIN
INSERT INTO agg_events INSERT INTO agg_events
(value_4_agg, (value_4_agg,
@ -1903,25 +1964,23 @@ INSERT INTO raw_events_first SELECT * FROM raw_events_second WHERE user_id = 5;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: distributed statement: INSERT INTO public.raw_events_first_13300000 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_second_13300004 raw_events_second WHERE ((user_id = 5) AND ((hashint4(user_id) >= '-2147483648'::integer) AND (hashint4(user_id) <= '-1073741825'::integer))) DEBUG: distributed statement: INSERT INTO public.raw_events_first_13300000 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_second_13300004 raw_events_second WHERE ((user_id = 5) AND ((hashint4(user_id) >= '-2147483648'::integer) AND (hashint4(user_id) <= '-1073741825'::integer)))
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300001 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300001 since it doesn't have the same shard range with the select anchor shard interval 13300004
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300002 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300002 since it doesn't have the same shard range with the select anchor shard interval 13300004
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300003 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300003 since it doesn't have the same shard range with the select anchor shard interval 13300004
DEBUG: ProcessQuery DEBUG: ProcessQuery
DEBUG: Plan is router executable DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
@ -1954,6 +2013,7 @@ INSERT INTO raw_events_first SELECT * FROM raw_events_second WHERE user_id = 5;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
@ -1964,25 +2024,23 @@ INSERT INTO raw_events_first SELECT * FROM raw_events_second WHERE user_id = 6;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300004 DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300000 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300000 since it doesn't have the same shard range with the select anchor shard interval 13300006
DEBUG: predicate pruning for shardId 13300004 DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300001 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300001 since it doesn't have the same shard range with the select anchor shard interval 13300006
DEBUG: predicate pruning for shardId 13300004 DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: distributed statement: INSERT INTO public.raw_events_first_13300002 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_second_13300006 raw_events_second WHERE ((user_id = 6) AND ((hashint4(user_id) >= 0) AND (hashint4(user_id) <= 1073741823))) DEBUG: distributed statement: INSERT INTO public.raw_events_first_13300002 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_second_13300006 raw_events_second WHERE ((user_id = 6) AND ((hashint4(user_id) >= 0) AND (hashint4(user_id) <= 1073741823)))
DEBUG: predicate pruning for shardId 13300004 DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300003 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300003 since it doesn't have the same shard range with the select anchor shard interval 13300006
DEBUG: ProcessQuery DEBUG: ProcessQuery
DEBUG: Plan is router executable DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand
@ -2043,25 +2101,23 @@ INSERT INTO raw_events_first SELECT * FROM raw_events_second WHERE user_id = 5;
DEBUG: StartTransactionCommand DEBUG: StartTransactionCommand
DEBUG: StartTransaction DEBUG: StartTransaction
DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children: DEBUG: name: unnamed; blockState: DEFAULT; state: INPROGR, xid/subid/cid: 0/1/0, nestlvl: 1, children:
DEBUG: skipping to add uninstantiated equality qual
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: distributed statement: INSERT INTO public.raw_events_first_13300000 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_second_13300004 raw_events_second WHERE ((user_id = 5) AND ((hashint4(user_id) >= '-2147483648'::integer) AND (hashint4(user_id) <= '-1073741825'::integer))) DEBUG: distributed statement: INSERT INTO public.raw_events_first_13300000 AS citus_table_alias (user_id, "time", value_1, value_2, value_3, value_4) SELECT user_id, "time", value_1, value_2, value_3, value_4 FROM public.raw_events_second_13300004 raw_events_second WHERE ((user_id = 5) AND ((hashint4(user_id) >= '-2147483648'::integer) AND (hashint4(user_id) <= '-1073741825'::integer)))
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300001 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300001 since it doesn't have the same shard range with the select anchor shard interval 13300004
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300002 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300002 since it doesn't have the same shard range with the select anchor shard interval 13300004
DEBUG: predicate pruning for shardId 13300004
DEBUG: predicate pruning for shardId 13300005 DEBUG: predicate pruning for shardId 13300005
DEBUG: predicate pruning for shardId 13300006 DEBUG: predicate pruning for shardId 13300006
DEBUG: predicate pruning for shardId 13300007 DEBUG: predicate pruning for shardId 13300007
DEBUG: Skipping target shard interval 13300003 since SELECT query for it pruned away DEBUG: Skipping target shard interval 13300003 since it doesn't have the same shard range with the select anchor shard interval 13300004
DEBUG: ProcessQuery DEBUG: ProcessQuery
DEBUG: Plan is router executable DEBUG: Plan is router executable
DEBUG: CommitTransactionCommand DEBUG: CommitTransactionCommand

View File

@ -539,8 +539,19 @@ FROM
raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.user_id raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.user_id
WHERE raw_events_first.user_id = 10 AND raw_events_second.user_id IN (19, 20, 21); WHERE raw_events_first.user_id = 10 AND raw_events_second.user_id IN (19, 20, 21);
-- some unsupported LEFT/INNER JOINs -- the following is a very tricky query for Citus
-- although we do not support pushing down JOINs on non-partition
-- columns here it is safe to push it down given that we're looking for
-- a specific value (i.e., value_1 = 12) on the joning column.
INSERT INTO agg_events
(user_id)
SELECT raw_events_first.user_id
FROM raw_events_first,
raw_events_second
WHERE raw_events_second.user_id = raw_events_first.value_1
AND raw_events_first.value_1 = 12;
-- some unsupported LEFT/INNER JOINs
-- JOIN on one table with partition column other is not -- JOIN on one table with partition column other is not
INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
SELECT SELECT
@ -571,20 +582,21 @@ FROM
-- JOIN on one table with partition column other is not -- JOIN on one table with partition column other is not
-- also an equality qual is added on the partition key -- also an equality qual is added on the partition key
--INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
--SELECT SELECT
-- raw_events_first.user_id raw_events_first.user_id
--FROM FROM
-- raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1 raw_events_first LEFT JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1
-- WHERE raw_events_first.user_id = 10; WHERE
raw_events_first.user_id = 10;
-- same as the above with INNER JOIN -- same as the above with INNER JOIN
--INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
--SELECT SELECT
-- raw_events_first.user_id raw_events_first.user_id
--FROM FROM
-- raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1 raw_events_first INNER JOIN raw_events_second ON raw_events_first.user_id = raw_events_second.value_1
-- WHERE raw_events_first.user_id = 10; WHERE raw_events_first.user_id = 10;
-- make things a bit more complicate with IN clauses -- make things a bit more complicate with IN clauses
INSERT INTO agg_events (user_id) INSERT INTO agg_events (user_id)
@ -602,6 +614,17 @@ FROM raw_events_first,
raw_events_second raw_events_second
WHERE raw_events_second.user_id = raw_events_first.value_1; WHERE raw_events_second.user_id = raw_events_first.value_1;
-- the following is again a very tricky query for Citus
-- if the given filter was on value_1 as shown in the above, Citus could
-- push it down. But here the query is refused
INSERT INTO agg_events
(user_id)
SELECT raw_events_first.user_id
FROM raw_events_first,
raw_events_second
WHERE raw_events_second.user_id = raw_events_first.value_1
AND raw_events_first.value_2 = 12;
-- unsupported JOIN -- unsupported JOIN
INSERT INTO agg_events INSERT INTO agg_events
(value_4_agg, (value_4_agg,