From 9c449112261c2e8f081514d3d5b5f972b26d64de Mon Sep 17 00:00:00 2001 From: SaitTalhaNisanci Date: Wed, 18 Nov 2020 17:16:06 +0300 Subject: [PATCH] Improve error messages in shard pruning (#4324) --- .../distributed/planner/shard_pruning.c | 7 +- .../regress/expected/multi_hash_pruning.out | 310 +++++++++--------- ...multi_repartition_join_task_assignment.out | 24 +- .../expected/multi_task_assignment_policy.out | 16 +- 4 files changed, 180 insertions(+), 177 deletions(-) diff --git a/src/backend/distributed/planner/shard_pruning.c b/src/backend/distributed/planner/shard_pruning.c index 1eebda1dc..9e720b235 100644 --- a/src/backend/distributed/planner/shard_pruning.c +++ b/src/backend/distributed/planner/shard_pruning.c @@ -486,6 +486,7 @@ PruneShards(Oid relationId, Index rangeTableId, List *whereClauseList, if (IsLoggableLevel(DEBUG3)) { + char *relationName = get_rel_name(relationId); if (foundRestriction && debugLoggedPruningInstances != NIL) { List *deparseCtx = deparse_context_for("unknown", relationId); @@ -497,10 +498,12 @@ PruneShards(Oid relationId, Index rangeTableId, List *whereClauseList, } else { - ereport(DEBUG3, (errmsg("no valid constraints found"))); + ereport(DEBUG3, (errmsg("no sharding pruning constraints on %s found", + relationName))); } - ereport(DEBUG3, (errmsg("shard count: %d", list_length(prunedList)))); + ereport(DEBUG3, (errmsg("shard count after pruning for %s: %d", relationName, + list_length(prunedList)))); } /* if requested, copy the partition value constant */ diff --git a/src/test/regress/expected/multi_hash_pruning.out b/src/test/regress/expected/multi_hash_pruning.out index 66ef3336f..ed7d935f8 100644 --- a/src/test/regress/expected/multi_hash_pruning.out +++ b/src/test/regress/expected/multi_hash_pruning.out @@ -239,12 +239,12 @@ SELECT count(*) FROM lineitem_hash_part DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 3 +DEBUG: shard count after pruning for lineitem_hash_part: 3 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 3 +DEBUG: shard count after pruning for lineitem_hash_part: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -258,12 +258,12 @@ SELECT count(*) FROM lineitem_hash_part DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 3 +DEBUG: shard count after pruning for lineitem_hash_part: 3 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 3 +DEBUG: shard count after pruning for lineitem_hash_part: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -283,11 +283,11 @@ DEBUG: Creating router plan SELECT count(*) FROM lineitem_hash_part WHERE l_orderkey = ANY (NULL); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -299,11 +299,11 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM lineitem_hash_part WHERE l_orderkey IN (NULL) OR TRUE; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -315,11 +315,11 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM lineitem_hash_part WHERE l_orderkey = ANY (NULL) OR TRUE; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -331,15 +331,15 @@ DEBUG: assigned task to node localhost:xxxxx -- Check whether we support IN/ANY in subquery SELECT count(*) FROM lineitem_hash_part WHERE l_orderkey IN (SELECT l_orderkey FROM lineitem_hash_part); -DEBUG: no valid constraints found -DEBUG: shard count: 4 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -350,15 +350,15 @@ DEBUG: assigned task to node localhost:xxxxx (1 row) SELECT count(*) FROM lineitem_hash_part WHERE l_orderkey = ANY (SELECT l_orderkey FROM lineitem_hash_part); -DEBUG: no valid constraints found -DEBUG: shard count: 4 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 +DEBUG: no sharding pruning constraints on lineitem_hash_part found +DEBUG: shard count after pruning for lineitem_hash_part: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -374,7 +374,7 @@ SELECT count(*) FROM lineitem DEBUG: Router planner does not support append-partitioned tables. DEBUG: constraint (lteq) value: '3'::bigint DEBUG: constraint (gteq) value: '1'::bigint -DEBUG: shard count: 1 +DEBUG: shard count after pruning for lineitem: 1 DEBUG: assigned task to node localhost:xxxxx count --------------------------------------------------------------------- @@ -386,7 +386,7 @@ SELECT count(*) FROM lineitem DEBUG: Router planner does not support append-partitioned tables. DEBUG: constraint (lteq) value: '3'::bigint DEBUG: constraint (gteq) value: '1'::bigint -DEBUG: shard count: 1 +DEBUG: shard count after pruning for lineitem: 1 DEBUG: assigned task to node localhost:xxxxx count --------------------------------------------------------------------- @@ -400,7 +400,7 @@ DEBUG: Router planner does not support append-partitioned tables. DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 1 +DEBUG: shard count after pruning for lineitem: 1 DEBUG: assigned task to node localhost:xxxxx count --------------------------------------------------------------------- @@ -413,7 +413,7 @@ DEBUG: Router planner does not support append-partitioned tables. DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 1 +DEBUG: shard count after pruning for lineitem: 1 DEBUG: assigned task to node localhost:xxxxx count --------------------------------------------------------------------- @@ -423,8 +423,8 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM lineitem WHERE l_orderkey = ANY(NULL) OR TRUE; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 2 +DEBUG: no sharding pruning constraints on lineitem found +DEBUG: shard count after pruning for lineitem: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -437,7 +437,7 @@ SELECT count(*) FROM lineitem_range DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 1 +DEBUG: shard count after pruning for lineitem_range: 1 DEBUG: Creating router plan count --------------------------------------------------------------------- @@ -449,7 +449,7 @@ SELECT count(*) FROM lineitem_range DEBUG: constraint value: '1'::bigint DEBUG: constraint value: '2'::bigint DEBUG: constraint value: '3'::bigint -DEBUG: shard count: 1 +DEBUG: shard count after pruning for lineitem_range: 1 DEBUG: Creating router plan count --------------------------------------------------------------------- @@ -458,11 +458,11 @@ DEBUG: Creating router plan SELECT count(*) FROM lineitem_range WHERE l_orderkey = ANY(NULL) OR TRUE; -DEBUG: no valid constraints found -DEBUG: shard count: 2 +DEBUG: no sharding pruning constraints on lineitem_range found +DEBUG: shard count after pruning for lineitem_range: 2 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 2 +DEBUG: no sharding pruning constraints on lineitem_range found +DEBUG: shard count after pruning for lineitem_range: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -474,11 +474,11 @@ DEBUG: assigned task to node localhost:xxxxx -- equality operator SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey < ALL ('{1,2,3}'); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -492,11 +492,11 @@ DEBUG: assigned task to node localhost:xxxxx -- columns are used with ANY/IN/ALL SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR o_totalprice IN (20, 30); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -508,11 +508,11 @@ DEBUG: assigned task to node localhost:xxxxx -- Check that we cannot prune for mutable functions. SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = (random() + 100); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -524,11 +524,11 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = (random() + 100) OR o_orderkey = 1; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -541,7 +541,7 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = (random() + 100) AND o_orderkey = 1; DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 1 count @@ -553,15 +553,15 @@ DEBUG: query has a single distribution column value: 1 SELECT count(*) FROM orders_hash_partitioned orders1, orders_hash_partitioned orders2 WHERE orders1.o_orderkey = orders2.o_orderkey; -DEBUG: no valid constraints found -DEBUG: shard count: 4 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: join prunable for intervals [-2147483648,-1073741825] and [-1073741824,-1] DEBUG: join prunable for intervals [-2147483648,-1073741825] and [0,1073741823] DEBUG: join prunable for intervals [-2147483648,-1073741825] and [1073741824,2147483647] @@ -589,9 +589,9 @@ SELECT count(*) AND orders1.o_orderkey = 1 AND orders2.o_orderkey is NULL; DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 1 count @@ -601,11 +601,11 @@ DEBUG: query has a single distribution column value: 1 -- All shards used without constraints SELECT count(*) FROM orders_hash_partitioned; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -619,7 +619,7 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1; DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 1 count @@ -631,7 +631,7 @@ DEBUG: query has a single distribution column value: 1 SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 AND (o_custkey = 11 OR o_custkey = 22); DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 1 count @@ -644,11 +644,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE (o_orderkey = 1 OR o_orderkey = 2); DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -661,11 +661,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE (o_orderkey = 1 OR o_orderkey = 2) AND (o_custkey = 11 OR o_custkey = 22); DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -680,13 +680,13 @@ DEBUG: constraint value: 1 DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -699,11 +699,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE (o_orderkey IN (1,2)) AND (o_custkey = 11 OR o_custkey = 22 OR o_custkey = 33); DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -716,11 +716,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE (o_orderkey IN (1,2)) AND (o_totalprice < 11 OR o_totalprice > 19) AND o_shippriority > 100 AND (o_custkey = 11 OR o_custkey = 22); DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -735,13 +735,13 @@ DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -753,11 +753,11 @@ DEBUG: assigned task to node localhost:xxxxx -- All shards used with prunable expression ORed with unprunable expression SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey IN (1,2) OR o_custkey = 33; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -773,12 +773,12 @@ SELECT count(*) FROM orders_hash_partitioned DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -792,11 +792,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR (o_orderkey = 2 AND (o_custkey = 11 OR (o_orderkey = 3 AND o_custkey = 44))); DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -809,11 +809,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE (o_orderkey IN (1,2)) AND (o_custkey = 11 OR o_custkey = 22 OR o_custkey = 33) AND o_totalprice <= 20; DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -826,11 +826,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE (o_orderkey IN (1,2)) AND (o_custkey = 11 OR o_custkey = 33) AND o_custkey = 22; DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -841,11 +841,11 @@ DEBUG: assigned task to node localhost:xxxxx -- All shards used with prunable SAO constraint ORed with unprunable nested expression SELECT count(*) FROM orders_hash_partitioned WHERE ((o_orderkey IN (1,2)) AND (o_custkey = 11 OR o_custkey = 22)) OR o_custkey = 33; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -861,12 +861,12 @@ SELECT count(*) FROM orders_hash_partitioned DEBUG: constraint value: 3 DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 3 DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -878,11 +878,11 @@ DEBUG: assigned task to node localhost:xxxxx -- All shards used with ORed top level unprunable expression SELECT count(*) FROM orders_hash_partitioned WHERE o_custkey = 11 OR (o_orderkey = 2 AND o_custkey = 22); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -896,7 +896,7 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR (o_orderkey = 2 AND (o_orderkey = 3 OR (o_orderkey = 1 AND o_custkey = 11))); DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan count --------------------------------------------------------------------- @@ -906,8 +906,8 @@ DEBUG: Creating router plan -- Single shard used when top prunable expression is restrictive with nested ANDs SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 AND ((o_orderkey = 2 OR o_orderkey = 3) AND (o_custkey = 11 OR o_custkey = 22)); -DEBUG: no valid constraints found -DEBUG: shard count: 0 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 0 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 1 count @@ -921,12 +921,12 @@ SELECT count(*) FROM orders_hash_partitioned DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 3 +DEBUG: shard count after pruning for orders_hash_partitioned: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -938,11 +938,11 @@ DEBUG: assigned task to node localhost:xxxxx -- Deeply nested non prunable expression uses all shards SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR ((o_orderkey = 2 OR o_custkey = 11) AND (o_custkey = 22 OR o_custkey = 33)); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -955,11 +955,11 @@ DEBUG: assigned task to node localhost:xxxxx -- a OR partkey != x Uses all shards SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR o_orderkey != 2; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -972,11 +972,11 @@ DEBUG: assigned task to node localhost:xxxxx -- a OR partkey IS NULL Uses all shards SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR o_orderkey IS NULL; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -989,11 +989,11 @@ DEBUG: assigned task to node localhost:xxxxx -- a OR partkey IS NOT NULL Uses all shards SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1 OR o_orderkey IS NOT NULL; -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -1015,11 +1015,11 @@ DEBUG: Creating router plan -- Check that NOT is handled with EQs ORed SELECT count(*) FROM orders_hash_partitioned WHERE NOT (o_orderkey = 2 OR o_orderkey = 3); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -1034,11 +1034,11 @@ SELECT count(*) FROM orders_hash_partitioned WHERE NOT (o_orderkey != 2 AND o_orderkey != 3); DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 2 DEBUG: constraint value: 3 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -1049,11 +1049,11 @@ DEBUG: assigned task to node localhost:xxxxx -- Check that NOT is handled with EQs ANDed SELECT count(*) FROM orders_hash_partitioned WHERE NOT (o_orderkey = 2 AND o_orderkey = 3); -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -1067,24 +1067,24 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey IN (1,2) AND o_custkey NOT IN (SELECT o_custkey FROM orders_hash_partitioned WHERE o_orderkey = 1); DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 1 DEBUG: generating subplan XXX_1 for subquery SELECT o_custkey FROM public.orders_hash_partitioned WHERE (o_orderkey OPERATOR(pg_catalog.=) 1) DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM public.orders_hash_partitioned WHERE ((o_orderkey OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2])) AND (NOT (o_custkey OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.o_custkey FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(o_custkey integer))))) DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 1 DEBUG: constraint value: 2 -DEBUG: shard count: 2 +DEBUG: shard count after pruning for orders_hash_partitioned: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx count @@ -1096,21 +1096,21 @@ DEBUG: assigned task to node localhost:xxxxx SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey IN (1,2) OR o_custkey NOT IN (SELECT o_custkey FROM orders_hash_partitioned WHERE o_orderkey = 3); DEBUG: constraint value: 3 -DEBUG: shard count: 1 -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries DEBUG: constraint value: 3 -DEBUG: shard count: 1 +DEBUG: shard count after pruning for orders_hash_partitioned: 1 DEBUG: Creating router plan DEBUG: query has a single distribution column value: 3 DEBUG: generating subplan XXX_1 for subquery SELECT o_custkey FROM public.orders_hash_partitioned WHERE (o_orderkey OPERATOR(pg_catalog.=) 3) DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM public.orders_hash_partitioned WHERE ((o_orderkey OPERATOR(pg_catalog.=) ANY (ARRAY[1, 2])) OR (NOT (o_custkey OPERATOR(pg_catalog.=) ANY (SELECT intermediate_result.o_custkey FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(o_custkey integer))))) -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: Router planner cannot handle multi-shard select queries -DEBUG: no valid constraints found -DEBUG: shard count: 4 +DEBUG: no sharding pruning constraints on orders_hash_partitioned found +DEBUG: shard count after pruning for orders_hash_partitioned: 4 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx diff --git a/src/test/regress/expected/multi_repartition_join_task_assignment.out b/src/test/regress/expected/multi_repartition_join_task_assignment.out index 7d00a08c1..77d0158bc 100644 --- a/src/test/regress/expected/multi_repartition_join_task_assignment.out +++ b/src/test/regress/expected/multi_repartition_join_task_assignment.out @@ -18,12 +18,12 @@ FROM WHERE o_custkey = c_custkey; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 2 +DEBUG: no sharding pruning constraints on orders found +DEBUG: shard count after pruning for orders: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on customer_append found +DEBUG: shard count after pruning for customer_append: 3 DEBUG: join prunable for intervals [1,1000] and [1001,2000] DEBUG: join prunable for intervals [1,1000] and [6001,7000] DEBUG: join prunable for intervals [1001,2000] and [1,1000] @@ -56,13 +56,13 @@ WHERE o_custkey = c_custkey AND o_orderkey = l_orderkey; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on customer_append found +DEBUG: shard count after pruning for customer_append: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx -DEBUG: no valid constraints found -DEBUG: shard count: 2 +DEBUG: no sharding pruning constraints on lineitem found +DEBUG: shard count after pruning for lineitem: 2 DEBUG: join prunable for intervals [1,5986] and [8997,14947] DEBUG: join prunable for intervals [8997,14947] and [1,5986] DEBUG: pruning merge fetch taskId 1 @@ -85,12 +85,12 @@ FROM WHERE l_partkey = c_nationkey; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 2 +DEBUG: no sharding pruning constraints on lineitem found +DEBUG: shard count after pruning for lineitem: 2 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on customer_append found +DEBUG: shard count after pruning for customer_append: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx diff --git a/src/test/regress/expected/multi_task_assignment_policy.out b/src/test/regress/expected/multi_task_assignment_policy.out index 4cb629fa0..4c52df355 100644 --- a/src/test/regress/expected/multi_task_assignment_policy.out +++ b/src/test/regress/expected/multi_task_assignment_policy.out @@ -70,8 +70,8 @@ SET client_min_messages TO DEBUG3; SET citus.task_assignment_policy TO 'greedy'; EXPLAIN (COSTS OFF) SELECT count(*) FROM task_assignment_test_table; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on task_assignment_test_table found +DEBUG: shard count after pruning for task_assignment_test_table: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -84,8 +84,8 @@ DEBUG: assigned task to node localhost:xxxxx EXPLAIN (COSTS OFF) SELECT count(*) FROM task_assignment_test_table; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on task_assignment_test_table found +DEBUG: shard count after pruning for task_assignment_test_table: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -100,8 +100,8 @@ DEBUG: assigned task to node localhost:xxxxx SET citus.task_assignment_policy TO 'first-replica'; EXPLAIN (COSTS OFF) SELECT count(*) FROM task_assignment_test_table; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on task_assignment_test_table found +DEBUG: shard count after pruning for task_assignment_test_table: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx @@ -114,8 +114,8 @@ DEBUG: assigned task to node localhost:xxxxx EXPLAIN (COSTS OFF) SELECT count(*) FROM task_assignment_test_table; DEBUG: Router planner does not support append-partitioned tables. -DEBUG: no valid constraints found -DEBUG: shard count: 3 +DEBUG: no sharding pruning constraints on task_assignment_test_table found +DEBUG: shard count after pruning for task_assignment_test_table: 3 DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx DEBUG: assigned task to node localhost:xxxxx