Merge pull request #1351 from citusdata/feature/remove_pruning_debug

Remove Pruning Debug Output
pull/1028/merge
Andres Freund 2017-04-26 11:58:52 -07:00 committed by GitHub
commit d70312ddc1
19 changed files with 814 additions and 1584 deletions

View File

@ -2655,12 +2655,7 @@ PruneShardList(Oid relationId, Index tableId, List *whereClauseList,
shardPruned = predicate_refuted_by(constraintList, restrictInfoList);
}
if (shardPruned)
{
ereport(DEBUG2, (errmsg("predicate pruning for shardId "
UINT64_FORMAT, shardInterval->shardId)));
}
else
if (!shardPruned)
{
remainingShardList = lappend(remainingShardList, shardInterval);
}

View File

@ -39,9 +39,6 @@ SELECT count(*) FROM orders_hash_partitioned;
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1;
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -50,9 +47,6 @@ DEBUG: Plan is router executable
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 2;
DEBUG: predicate pruning for shardId 630000
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -61,9 +55,6 @@ DEBUG: Plan is router executable
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 3;
DEBUG: predicate pruning for shardId 630000
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -72,9 +63,6 @@ DEBUG: Plan is router executable
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 4;
DEBUG: predicate pruning for shardId 630000
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -84,9 +72,6 @@ DEBUG: Plan is router executable
SELECT count(*) FROM orders_hash_partitioned
WHERE o_orderkey = 1 AND o_clerk = 'aaa';
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -95,9 +80,6 @@ DEBUG: Plan is router executable
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = abs(-1);
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -114,36 +96,24 @@ SELECT count(*) FROM orders_hash_partitioned;
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 1;
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
count
-------
0
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 2;
DEBUG: predicate pruning for shardId 630000
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
count
-------
0
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 3;
DEBUG: predicate pruning for shardId 630000
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
count
-------
0
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = 4;
DEBUG: predicate pruning for shardId 630000
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
count
-------
0
@ -151,18 +121,12 @@ DEBUG: predicate pruning for shardId 630003
SELECT count(*) FROM orders_hash_partitioned
WHERE o_orderkey = 1 AND o_clerk = 'aaa';
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
count
-------
0
(1 row)
SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey = abs(-1);
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
count
-------
0
@ -189,10 +153,6 @@ SELECT count(*) FROM orders_hash_partitioned WHERE o_orderkey > 2;
SELECT count(*) FROM orders_hash_partitioned
WHERE o_orderkey = 1 OR o_orderkey = 2;
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
count
-------
0
@ -207,10 +167,6 @@ SELECT count(*) FROM orders_hash_partitioned
SELECT count(*) FROM orders_hash_partitioned
WHERE o_orderkey = 1 OR (o_orderkey = 3 AND o_clerk = 'aaa');
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
count
-------
0
@ -225,9 +181,6 @@ SELECT count(*) FROM orders_hash_partitioned
SELECT count(*) FROM
(SELECT o_orderkey FROM orders_hash_partitioned WHERE o_orderkey = 1) AS orderkeys;
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -282,9 +235,6 @@ SELECT count(*) FROM orders_hash_partitioned
SELECT count(*) FROM orders_hash_partitioned
WHERE o_orderkey = random() AND o_orderkey = 1;
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
@ -318,12 +268,6 @@ SELECT count(*)
WHERE orders1.o_orderkey = orders2.o_orderkey
AND orders1.o_orderkey = 1
AND orders2.o_orderkey is NULL;
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: predicate pruning for shardId 630001
DEBUG: predicate pruning for shardId 630002
DEBUG: predicate pruning for shardId 630003
DEBUG: Creating router plan
DEBUG: Plan is router executable
count

File diff suppressed because it is too large Load Diff

View File

@ -25,10 +25,6 @@ DEBUG: join prunable for intervals [13473,14947] and [1,5986]
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey AND l_orderkey > 9030;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: join prunable for intervals [8997,10560] and [1,5986]
DEBUG: join prunable for intervals [10560,12036] and [1,5986]
DEBUG: join prunable for intervals [12036,13473] and [1,5986]
@ -42,14 +38,6 @@ DEBUG: join prunable for intervals [13473,14947] and [1,5986]
-- works as expected in this case.
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey AND l_orderkey > 20000;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290004
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
sum | avg
-----+-----
|
@ -60,11 +48,6 @@ DEBUG: predicate pruning for shardId 290007
-- out all the shards, and leave us with an empty task list.
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey AND l_orderkey > 6000 AND o_orderkey < 6000;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290009
DEBUG: join prunable for intervals [8997,10560] and [1,5986]
DEBUG: join prunable for intervals [10560,12036] and [1,5986]
DEBUG: join prunable for intervals [12036,13473] and [1,5986]

View File

@ -9,6 +9,36 @@ SET citus.large_table_shard_count TO 2;
SET client_min_messages TO DEBUG2;
SET citus.task_executor_type TO 'task-tracker';
-- Single range-repartition join to test join-pruning behaviour.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
orders, customer
WHERE
o_custkey = c_custkey;
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]
DEBUG: join prunable for intervals [1001,2000] and [6001,7000]
DEBUG: join prunable for intervals [6001,7000] and [1,1000]
DEBUG: join prunable for intervals [6001,7000] and [1001,2000]
DEBUG: pruning merge fetch taskId 1
DETAIL: Creating dependency on merge taskId 5
DEBUG: pruning merge fetch taskId 4
DETAIL: Creating dependency on merge taskId 8
DEBUG: pruning merge fetch taskId 7
DETAIL: Creating dependency on merge taskId 11
QUERY PLAN
-------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Task-Tracker)
Task Count: 3
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 2
Merge Task Count: 3
(7 rows)
SELECT
count(*)
FROM
@ -34,6 +64,25 @@ DETAIL: Creating dependency on merge taskId 11
-- Single range-repartition join with a selection clause on the partitioned
-- table to test the case when all map tasks are pruned away.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
orders, customer
WHERE
o_custkey = c_custkey AND
o_orderkey < 0;
QUERY PLAN
-------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 0
Merge Task Count: 0
(7 rows)
SELECT
count(*)
FROM
@ -41,8 +90,6 @@ FROM
WHERE
o_custkey = c_custkey AND
o_orderkey < 0;
DEBUG: predicate pruning for shardId 290008
DEBUG: predicate pruning for shardId 290009
count
-------
0
@ -50,6 +97,25 @@ DEBUG: predicate pruning for shardId 290009
-- Single range-repartition join with a selection clause on the base table to
-- test the case when all sql tasks are pruned away.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
orders, customer
WHERE
o_custkey = c_custkey AND
c_custkey < 0;
QUERY PLAN
-------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 2
Merge Task Count: 3
(7 rows)
SELECT
count(*)
FROM
@ -57,9 +123,6 @@ FROM
WHERE
o_custkey = c_custkey AND
c_custkey < 0;
DEBUG: predicate pruning for shardId 290010
DEBUG: predicate pruning for shardId 280001
DEBUG: predicate pruning for shardId 280000
count
-------
0
@ -68,6 +131,55 @@ DEBUG: predicate pruning for shardId 280000
-- Dual hash-repartition join test case. Note that this query doesn't produce
-- meaningful results and is only to test hash-partitioning of two large tables
-- on non-partition columns.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
lineitem, customer
WHERE
l_partkey = c_nationkey;
DEBUG: join prunable for task partitionId 0 and 1
DEBUG: join prunable for task partitionId 0 and 2
DEBUG: join prunable for task partitionId 0 and 3
DEBUG: join prunable for task partitionId 1 and 0
DEBUG: join prunable for task partitionId 1 and 2
DEBUG: join prunable for task partitionId 1 and 3
DEBUG: join prunable for task partitionId 2 and 0
DEBUG: join prunable for task partitionId 2 and 1
DEBUG: join prunable for task partitionId 2 and 3
DEBUG: join prunable for task partitionId 3 and 0
DEBUG: join prunable for task partitionId 3 and 1
DEBUG: join prunable for task partitionId 3 and 2
DEBUG: pruning merge fetch taskId 1
DETAIL: Creating dependency on merge taskId 17
DEBUG: pruning merge fetch taskId 2
DETAIL: Creating dependency on merge taskId 7
DEBUG: pruning merge fetch taskId 4
DETAIL: Creating dependency on merge taskId 26
DEBUG: pruning merge fetch taskId 5
DETAIL: Creating dependency on merge taskId 11
DEBUG: pruning merge fetch taskId 7
DETAIL: Creating dependency on merge taskId 35
DEBUG: pruning merge fetch taskId 8
DETAIL: Creating dependency on merge taskId 15
DEBUG: pruning merge fetch taskId 10
DETAIL: Creating dependency on merge taskId 44
DEBUG: pruning merge fetch taskId 11
DETAIL: Creating dependency on merge taskId 19
QUERY PLAN
-------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Task-Tracker)
Task Count: 4
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 8
Merge Task Count: 4
-> MapMergeJob
Map Task Count: 3
Merge Task Count: 4
(10 rows)
SELECT
count(*)
FROM
@ -109,6 +221,28 @@ DETAIL: Creating dependency on merge taskId 19
-- Dual hash-repartition join with a selection clause on one of the tables to
-- test the case when all map tasks are pruned away.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
lineitem, customer
WHERE
l_partkey = c_nationkey AND
l_orderkey < 0;
QUERY PLAN
-------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 0
Merge Task Count: 0
-> MapMergeJob
Map Task Count: 3
Merge Task Count: 4
(10 rows)
SELECT
count(*)
FROM
@ -116,20 +250,30 @@ FROM
WHERE
l_partkey = c_nationkey AND
l_orderkey < 0;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290004
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
count
-------
0
(1 row)
-- Test cases with false in the WHERE clause
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
orders INNER JOIN customer ON (o_custkey = c_custkey)
WHERE
false;
QUERY PLAN
-------------------------------------------------------------
Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 0
Merge Task Count: 0
(6 rows)
-- execute once, to verify that's handled
SELECT
o_orderkey
FROM
@ -140,31 +284,46 @@ WHERE
------------
(0 rows)
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
orders INNER JOIN customer ON (o_custkey = c_custkey)
WHERE
1=0 AND c_custkey < 0;
o_orderkey
------------
(0 rows)
QUERY PLAN
-------------------------------------------------------------
Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: None, not supported for re-partition queries
-> MapMergeJob
Map Task Count: 0
Merge Task Count: 0
(6 rows)
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
orders INNER JOIN customer ON (o_custkey = c_custkey AND false);
o_orderkey
------------
(0 rows)
QUERY PLAN
----------------------------------
Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: All
(3 rows)
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
orders, customer
WHERE
o_custkey = c_custkey AND false;
o_orderkey
------------
(0 rows)
QUERY PLAN
----------------------------------
Custom Scan (Citus Task-Tracker)
Task Count: 0
Tasks Shown: All
(3 rows)

View File

@ -118,7 +118,6 @@ INSERT INTO append_partitioned VALUES (414123, 'AAPL', 9580, '2004-10-19 10:23:5
SET client_min_messages TO 'DEBUG2';
SET citus.task_executor_type TO 'real-time';
SELECT * FROM range_partitioned WHERE id = 32743;
DEBUG: predicate pruning for shardId 750006
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | symbol | bidder_id | placed_at | kind | limit_price
@ -127,7 +126,6 @@ DEBUG: Plan is router executable
(1 row)
SELECT * FROM append_partitioned WHERE id = 414123;
DEBUG: predicate pruning for shardId 750008
DEBUG: Plan is router executable
id | symbol | bidder_id | placed_at | kind | limit_price
--------+--------+-----------+--------------------------+------+-------------

View File

@ -67,7 +67,6 @@ DEBUG: Plan is router executable
-- single-shard tests
-- test simple select for a single row
SELECT * FROM articles_hash_mx WHERE author_id = 10 AND id = 50;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -77,7 +76,6 @@ DEBUG: Plan is router executable
-- get all titles by a single author
SELECT title FROM articles_hash_mx WHERE author_id = 10;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
title
@ -93,7 +91,6 @@ DEBUG: Plan is router executable
SELECT title, word_count FROM articles_hash_mx
WHERE author_id = 10
ORDER BY word_count DESC NULLS LAST;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | word_count
@ -110,7 +107,6 @@ SELECT title, id FROM articles_hash_mx
WHERE author_id = 5
ORDER BY id
LIMIT 2;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | id
@ -124,7 +120,6 @@ DEBUG: Plan is router executable
SELECT title, author_id FROM articles_hash_mx
WHERE author_id = 7 OR author_id = 8
ORDER BY author_id ASC, id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | author_id
@ -144,7 +139,6 @@ DEBUG: Plan is router executable
-- same query is router executable with no order by
SELECT title, author_id FROM articles_hash_mx
WHERE author_id = 7 OR author_id = 8;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | author_id
@ -168,7 +162,6 @@ SELECT author_id, sum(word_count) AS corpus_size FROM articles_hash_mx
GROUP BY author_id
HAVING sum(word_count) > 1000
ORDER BY sum(word_count) DESC;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
author_id | corpus_size
@ -185,7 +178,6 @@ SELECT author_id, sum(word_count) AS corpus_size FROM articles_hash_mx
GROUP BY author_id
HAVING sum(word_count) > 1000
ORDER BY sum(word_count) DESC;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
author_id | corpus_size
@ -227,7 +219,6 @@ HINT: Consider rewriting the expression with OR/AND clauses.
-- queries with CTEs are supported
WITH first_author AS ( SELECT id FROM articles_hash_mx WHERE author_id = 1)
SELECT * FROM first_author;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -242,7 +233,6 @@ DEBUG: Plan is router executable
-- queries with CTEs are supported even if CTE is not referenced inside query
WITH first_author AS ( SELECT id FROM articles_hash_mx WHERE author_id = 1)
SELECT title FROM articles_hash_mx WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
title
@ -258,8 +248,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash_mx WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash_mx WHERE author_id = 1)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | id | title
@ -274,8 +262,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash_mx WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash_mx WHERE author_id = 3)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | id | title
@ -286,8 +272,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash_mx WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash_mx WHERE author_id = 2)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220104
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
-- recursive CTEs are supported when filtered on partition column
@ -327,12 +311,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 1))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 1220108
DEBUG: predicate pruning for shardId 1220109
DEBUG: predicate pruning for shardId 1220110
DEBUG: predicate pruning for shardId 1220108
DEBUG: predicate pruning for shardId 1220109
DEBUG: predicate pruning for shardId 1220110
DEBUG: Creating router plan
DEBUG: Plan is router executable
company_id | employee_id | manager_id | level
@ -354,9 +332,6 @@ WITH RECURSIVE hierarchy as (
ON (h.employee_id = ce.manager_id AND
h.company_id = ce.company_id))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 1220108
DEBUG: predicate pruning for shardId 1220109
DEBUG: predicate pruning for shardId 1220110
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
-- logically wrong query, query involves different shards
@ -373,12 +348,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 2))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 1220107
DEBUG: predicate pruning for shardId 1220109
DEBUG: predicate pruning for shardId 1220110
DEBUG: predicate pruning for shardId 1220107
DEBUG: predicate pruning for shardId 1220108
DEBUG: predicate pruning for shardId 1220109
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
-- grouping sets are supported on single shard
@ -387,7 +356,6 @@ SELECT
FROM articles_hash_mx
WHERE author_id = 1 or author_id = 3
GROUP BY GROUPING SETS ((id),(subtitle));
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | subtitle | count
@ -422,7 +390,6 @@ ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP
HINT: Consider using an equality filter on the distributed table's partition column.
-- queries which involve functions in FROM clause are supported if it goes to a single worker.
SELECT * FROM articles_hash_mx, position('om' in 'Thomas') WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | position
@ -435,7 +402,6 @@ DEBUG: Plan is router executable
(5 rows)
SELECT * FROM articles_hash_mx, position('om' in 'Thomas') WHERE author_id = 1 or author_id = 3;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | position
@ -503,8 +469,6 @@ SELECT articles_hash_mx.id,test.word_count
FROM articles_hash_mx, (SELECT id, word_count FROM articles_hash_mx) AS test
WHERE test.id = articles_hash_mx.id and articles_hash_mx.author_id = 1
ORDER BY articles_hash_mx.id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: join prunable for task partitionId 0 and 1
DEBUG: join prunable for task partitionId 0 and 2
DEBUG: join prunable for task partitionId 0 and 3
@ -544,7 +508,6 @@ HINT: Consider using an equality filter on the distributed table's partition co
SELECT *
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -560,7 +523,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE author_id = 1 OR author_id = 17;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -590,7 +552,6 @@ SELECT *
SELECT id as article_id, word_count * id as random_value
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
article_id | random_value
@ -607,8 +568,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash_mx a, articles_hash_mx b
WHERE a.author_id = 10 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -624,7 +583,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash_mx a, articles_single_shard_hash_mx b
WHERE a.author_id = 10 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -643,7 +601,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash_mx a, single_shard b
WHERE a.author_id = 2 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 1220104
DEBUG: Found no worker with all shard placements
ERROR: could not run distributed query with complex table expressions
-- single shard select with limit is router plannable
@ -651,7 +608,6 @@ SELECT *
FROM articles_hash_mx
WHERE author_id = 1
LIMIT 3;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -667,7 +623,6 @@ SELECT *
WHERE author_id = 1
LIMIT 2
OFFSET 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -683,7 +638,6 @@ SELECT *
ORDER BY id desc
LIMIT 2
OFFSET 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -699,7 +653,6 @@ SELECT id
WHERE author_id = 1
GROUP BY id
ORDER BY id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -716,7 +669,6 @@ SELECT distinct id
FROM articles_hash_mx
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -732,7 +684,6 @@ DEBUG: Plan is router executable
SELECT avg(word_count)
FROM articles_hash_mx
WHERE author_id = 2;
DEBUG: predicate pruning for shardId 1220104
DEBUG: Creating router plan
DEBUG: Plan is router executable
avg
@ -745,7 +696,6 @@ SELECT max(word_count) as max, min(word_count) as min,
sum(word_count) as sum, count(word_count) as cnt
FROM articles_hash_mx
WHERE author_id = 2;
DEBUG: predicate pruning for shardId 1220104
DEBUG: Creating router plan
DEBUG: Plan is router executable
max | min | sum | cnt
@ -758,7 +708,6 @@ SELECT max(word_count)
FROM articles_hash_mx
WHERE author_id = 1
GROUP BY author_id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
max
@ -771,8 +720,6 @@ DEBUG: Plan is router executable
(SELECT * FROM articles_hash_mx WHERE author_id = 1)
UNION
(SELECT * FROM articles_hash_mx WHERE author_id = 3);
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -793,8 +740,6 @@ SELECT * FROM (
(SELECT * FROM articles_hash_mx WHERE author_id = 1)
UNION
(SELECT * FROM articles_hash_mx WHERE author_id = 3)) uu;
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -814,8 +759,6 @@ DEBUG: Plan is router executable
(SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 1)
UNION
(SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 3);
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
left
@ -826,8 +769,6 @@ DEBUG: Plan is router executable
(SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 1)
INTERSECT
(SELECT LEFT(title, 1) FROM articles_hash_mx WHERE author_id = 3);
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
left
@ -838,8 +779,6 @@ DEBUG: Plan is router executable
(SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 1)
EXCEPT
(SELECT LEFT(title, 2) FROM articles_hash_mx WHERE author_id = 3);
DEBUG: predicate pruning for shardId 1220105
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
left
@ -903,7 +842,6 @@ SET client_min_messages to 'DEBUG2';
SELECT *
FROM articles_hash_mx
WHERE author_id = 1 and author_id >= 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -933,7 +871,6 @@ SELECT *
SELECT *
FROM articles_hash_mx
WHERE author_id = 1 and (id = 1 or id = 41);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -946,7 +883,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE author_id = 1 and (id = random()::int * 0);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -984,7 +920,6 @@ SELECT *
SELECT *
FROM articles_hash_mx
WHERE author_id = abs(-1);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1026,7 +961,6 @@ SELECT *
SELECT *
FROM articles_hash_mx
WHERE author_id = 1 and (id = abs(id - 2));
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1051,7 +985,6 @@ SELECT *
SELECT *
FROM articles_hash_mx
WHERE (author_id = 1) = true;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1067,7 +1000,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE (author_id = 1) and id between 0 and 20;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1080,7 +1012,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE (author_id = 1) and (id = 1 or id = 31) and title like '%s';
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1093,7 +1024,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE (id = 1 or id = 31) and title like '%s' and (author_id = 1);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1106,7 +1036,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE (title like '%s' or title like 'a%') and (author_id = 1);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1122,7 +1051,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash_mx
WHERE (title like '%s' or title like 'a%') and (author_id = 1) and (word_count < 3000 or word_count > 8000);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1136,7 +1064,6 @@ DEBUG: Plan is router executable
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
FROM articles_hash_mx
WHERE author_id = 5;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
prev | title | word_count
@ -1152,7 +1079,6 @@ SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
FROM articles_hash_mx
WHERE author_id = 5
ORDER BY word_count DESC;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
prev | title | word_count
@ -1167,7 +1093,6 @@ DEBUG: Plan is router executable
SELECT id, MIN(id) over (order by word_count)
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | min
@ -1182,7 +1107,6 @@ DEBUG: Plan is router executable
SELECT id, word_count, AVG(word_count) over (order by word_count)
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | word_count | avg
@ -1197,7 +1121,6 @@ DEBUG: Plan is router executable
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
word_count | rank
@ -1234,7 +1157,6 @@ SELECT
articles_hash_mx
WHERE
author_id = 5;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
c
@ -1276,7 +1198,6 @@ SELECT *
FROM articles_hash_mx
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1296,7 +1217,6 @@ DECLARE test_cursor CURSOR FOR
FROM articles_hash_mx
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
FETCH test_cursor;
@ -1324,7 +1244,6 @@ COPY (
FROM articles_hash_mx
WHERE author_id = 1
ORDER BY id) TO STDOUT;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
1 1 arsenous 9572
@ -1339,14 +1258,12 @@ CREATE TEMP TABLE temp_articles_hash_mx as
FROM articles_hash_mx
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
-- router plannable queries may include filter for aggragates
SELECT count(*), count(*) FILTER (WHERE id < 3)
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
count | count
@ -1369,7 +1286,6 @@ PREPARE author_1_articles as
FROM articles_hash_mx
WHERE author_id = 1;
EXECUTE author_1_articles;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1387,7 +1303,6 @@ PREPARE author_articles(int) as
FROM articles_hash_mx
WHERE author_id = $1;
EXECUTE author_articles(1);
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1411,18 +1326,6 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
SELECT author_articles_max_id();
DEBUG: predicate pruning for shardId 1220105
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash_mx ah
WHERE author_id = 1"
PL/pgSQL function author_articles_max_id() line 5 at SQL statement
DEBUG: predicate pruning for shardId 1220105
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash_mx ah
WHERE author_id = 1"
PL/pgSQL function author_articles_max_id() line 5 at SQL statement
DEBUG: predicate pruning for shardId 1220105
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash_mx ah
WHERE author_id = 1"
PL/pgSQL function author_articles_max_id() line 5 at SQL statement
DEBUG: Creating router plan
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash_mx ah
WHERE author_id = 1"
@ -1448,11 +1351,6 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
SELECT * FROM author_articles_id_word_count();
DEBUG: predicate pruning for shardId 1220105
CONTEXT: SQL statement "SELECT ah.id, ah.word_count
FROM articles_hash_mx ah
WHERE author_id = 1"
PL/pgSQL function author_articles_id_word_count() line 4 at RETURN QUERY
DEBUG: Creating router plan
CONTEXT: SQL statement "SELECT ah.id, ah.word_count
FROM articles_hash_mx ah
@ -1475,7 +1373,6 @@ PL/pgSQL function author_articles_id_word_count() line 4 at RETURN QUERY
-- materialized views can be created for router plannable queries
CREATE MATERIALIZED VIEW mv_articles_hash_mx AS
SELECT * FROM articles_hash_mx WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
SELECT * FROM mv_articles_hash_mx;
@ -1513,7 +1410,6 @@ DEBUG: Plan is router executable
SELECT id
FROM articles_hash_mx
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 1220105
DEBUG: Creating router plan
DEBUG: Plan is router executable
id

View File

@ -5,6 +5,10 @@
-- and that we don't partition or join prune shards that have null values.
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 760000;
SET client_min_messages TO DEBUG2;
SET citus.explain_all_tasks TO on;
-- to avoid differing explain output - executor doesn't matter,
-- because were testing pruning here.
SET citus.task_executor_type TO 'real-time';
-- Change configuration to treat lineitem and orders tables as large
SET citus.large_table_shard_count TO 2;
SELECT shardminvalue, shardmaxvalue from pg_dist_shard WHERE shardid = 290000;
@ -21,29 +25,34 @@ SELECT shardminvalue, shardmaxvalue from pg_dist_shard WHERE shardid = 290001;
-- Check that partition and join pruning works when min/max values exist
-- Adding l_orderkey = 1 to make the query not router executable
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030 or l_orderkey = 1;
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
l_orderkey | l_linenumber | l_shipdate
------------+--------------+------------
1 | 1 | 03-13-1996
1 | 2 | 04-12-1996
1 | 3 | 01-29-1996
1 | 4 | 04-21-1996
1 | 5 | 03-30-1996
1 | 6 | 01-30-1996
9030 | 1 | 09-02-1998
9030 | 2 | 08-19-1998
9030 | 3 | 08-27-1998
9030 | 4 | 07-20-1998
9030 | 5 | 09-29-1998
9030 | 6 | 09-03-1998
(12 rows)
QUERY PLAN
-----------------------------------------------------------------------
Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Bitmap Heap Scan on lineitem_290000 lineitem
Recheck Cond: ((l_orderkey = 9030) OR (l_orderkey = 1))
-> BitmapOr
-> Bitmap Index Scan on lineitem_pkey_290000
Index Cond: (l_orderkey = 9030)
-> Bitmap Index Scan on lineitem_pkey_290000
Index Cond: (l_orderkey = 1)
-> Task
Node: host=localhost port=57638 dbname=regression
-> Bitmap Heap Scan on lineitem_290004 lineitem
Recheck Cond: ((l_orderkey = 9030) OR (l_orderkey = 1))
-> BitmapOr
-> Bitmap Index Scan on lineitem_pkey_290004
Index Cond: (l_orderkey = 9030)
-> Bitmap Index Scan on lineitem_pkey_290004
Index Cond: (l_orderkey = 1)
(21 rows)
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
DEBUG: join prunable for intervals [1,1509] and [8997,14946]
@ -54,31 +63,91 @@ DEBUG: join prunable for intervals [8997,10560] and [1,5986]
DEBUG: join prunable for intervals [10560,12036] and [1,5986]
DEBUG: join prunable for intervals [12036,13473] and [1,5986]
DEBUG: join prunable for intervals [13473,14947] and [1,5986]
sum | avg
-------+--------------------
36086 | 3.0076679446574429
(1 row)
QUERY PLAN
------------------------------------------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 8
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (lineitem.l_orderkey = orders.o_orderkey)
-> Index Only Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290003 on lineitem_290003 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290002 on lineitem_290002 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290005 on lineitem_290005 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290007 on lineitem_290007 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290006 on lineitem_290006 lineitem
(60 rows)
-- Now set the minimum value for a shard to null. Then check that we don't apply
-- partition or join pruning for the shard with null min value.
UPDATE pg_dist_shard SET shardminvalue = NULL WHERE shardid = 290000;
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030;
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
l_orderkey | l_linenumber | l_shipdate
------------+--------------+------------
9030 | 1 | 09-02-1998
9030 | 2 | 08-19-1998
9030 | 3 | 08-27-1998
9030 | 4 | 07-20-1998
9030 | 5 | 09-29-1998
9030 | 6 | 09-03-1998
(6 rows)
QUERY PLAN
-------------------------------------------------------------------------------
Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Index Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
Index Cond: (l_orderkey = 9030)
-> Task
Node: host=localhost port=57638 dbname=regression
-> Index Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
Index Cond: (l_orderkey = 9030)
(11 rows)
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
DEBUG: join prunable for intervals [1509,2951] and [8997,14946]
@ -88,30 +157,102 @@ DEBUG: join prunable for intervals [8997,10560] and [1,5986]
DEBUG: join prunable for intervals [10560,12036] and [1,5986]
DEBUG: join prunable for intervals [12036,13473] and [1,5986]
DEBUG: join prunable for intervals [13473,14947] and [1,5986]
sum | avg
-------+--------------------
36086 | 3.0076679446574429
(1 row)
QUERY PLAN
------------------------------------------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 9
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (lineitem.l_orderkey = orders.o_orderkey)
-> Index Only Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290003 on lineitem_290003 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290005 on lineitem_290005 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290002 on lineitem_290002 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290007 on lineitem_290007 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290006 on lineitem_290006 lineitem
(67 rows)
-- Next, set the maximum value for another shard to null. Then check that we
-- don't apply partition or join pruning for this other shard either.
UPDATE pg_dist_shard SET shardmaxvalue = NULL WHERE shardid = 290001;
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030;
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
l_orderkey | l_linenumber | l_shipdate
------------+--------------+------------
9030 | 1 | 09-02-1998
9030 | 2 | 08-19-1998
9030 | 3 | 08-27-1998
9030 | 4 | 07-20-1998
9030 | 5 | 09-29-1998
9030 | 6 | 09-03-1998
(6 rows)
QUERY PLAN
-------------------------------------------------------------------------------
Custom Scan (Citus Real-Time)
Task Count: 3
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Index Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
Index Cond: (l_orderkey = 9030)
-> Task
Node: host=localhost port=57638 dbname=regression
-> Index Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
Index Cond: (l_orderkey = 9030)
-> Task
Node: host=localhost port=57637 dbname=regression
-> Index Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
Index Cond: (l_orderkey = 9030)
(15 rows)
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
DEBUG: join prunable for intervals [2951,4455] and [8997,14946]
@ -120,31 +261,105 @@ DEBUG: join prunable for intervals [8997,10560] and [1,5986]
DEBUG: join prunable for intervals [10560,12036] and [1,5986]
DEBUG: join prunable for intervals [12036,13473] and [1,5986]
DEBUG: join prunable for intervals [13473,14947] and [1,5986]
sum | avg
-------+--------------------
36086 | 3.0076679446574429
(1 row)
QUERY PLAN
------------------------------------------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 10
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (lineitem.l_orderkey = orders.o_orderkey)
-> Index Only Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290003 on lineitem_290003 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290002 on lineitem_290002 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290005 on lineitem_290005 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290007 on lineitem_290007 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290006 on lineitem_290006 lineitem
(74 rows)
-- Last, set the minimum value to 0 and check that we don't treat it as null. We
-- should apply partition and join pruning for this shard now.
UPDATE pg_dist_shard SET shardminvalue = '0' WHERE shardid = 290000;
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
l_orderkey | l_linenumber | l_shipdate
------------+--------------+------------
9030 | 1 | 09-02-1998
9030 | 2 | 08-19-1998
9030 | 3 | 08-27-1998
9030 | 4 | 07-20-1998
9030 | 5 | 09-29-1998
9030 | 6 | 09-03-1998
(6 rows)
QUERY PLAN
-------------------------------------------------------------------------------
Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Index Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
Index Cond: (l_orderkey = 9030)
-> Task
Node: host=localhost port=57638 dbname=regression
-> Index Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
Index Cond: (l_orderkey = 9030)
(11 rows)
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
DEBUG: join prunable for intervals [0,1509] and [8997,14946]
@ -154,10 +369,76 @@ DEBUG: join prunable for intervals [8997,10560] and [1,5986]
DEBUG: join prunable for intervals [10560,12036] and [1,5986]
DEBUG: join prunable for intervals [12036,13473] and [1,5986]
DEBUG: join prunable for intervals [13473,14947] and [1,5986]
sum | avg
-------+--------------------
36086 | 3.0076679446574429
(1 row)
QUERY PLAN
------------------------------------------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 9
Tasks Shown: All
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (lineitem.l_orderkey = orders.o_orderkey)
-> Index Only Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290002 on lineitem_290002 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290008 on orders_290008 orders
-> Index Only Scan using lineitem_pkey_290003 on lineitem_290003 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290004 on lineitem_290004 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290005 on lineitem_290005 lineitem
-> Task
Node: host=localhost port=57638 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290006 on lineitem_290006 lineitem
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate
-> Merge Join
Merge Cond: (orders.o_orderkey = lineitem.l_orderkey)
-> Index Only Scan using orders_pkey_290009 on orders_290009 orders
-> Index Only Scan using lineitem_pkey_290007 on lineitem_290007 lineitem
(67 rows)
-- Set minimum and maximum values for two shards back to their original values
UPDATE pg_dist_shard SET shardminvalue = '1' WHERE shardid = 290000;

View File

@ -4,16 +4,8 @@
-- Tests to verify that we correctly prune unreferenced shards. For this, we
-- need to increase the logging verbosity of messages displayed on the client.
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 770000;
SET citus.explain_distributed_queries TO off;
SET client_min_messages TO DEBUG2;
-- Adding additional l_orderkey = 1 to make this query not router executable
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030 or l_orderkey = 1;
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
l_orderkey | l_linenumber | l_shipdate
------------+--------------+------------
1 | 1 | 03-13-1996
@ -36,10 +28,6 @@ DEBUG: predicate pruning for shardId 290007
-- trigger the the creation of toasted tables and indexes. This in turn prints
-- non-deterministic debug messages. To avoid this chain, we use l_linenumber.
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem WHERE l_orderkey > 9030;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
sum | avg
-------+--------------------
17999 | 3.0189533713518953
@ -47,7 +35,6 @@ DEBUG: predicate pruning for shardId 290003
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem
WHERE (l_orderkey < 4000 OR l_orderkey > 9030);
DEBUG: predicate pruning for shardId 290003
sum | avg
-------+--------------------
30184 | 3.0159872102318145
@ -55,14 +42,6 @@ DEBUG: predicate pruning for shardId 290003
-- The following query should prune out all shards and return empty results
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem WHERE l_orderkey > 20000;
DEBUG: predicate pruning for shardId 290000
DEBUG: predicate pruning for shardId 290001
DEBUG: predicate pruning for shardId 290002
DEBUG: predicate pruning for shardId 290003
DEBUG: predicate pruning for shardId 290004
DEBUG: predicate pruning for shardId 290005
DEBUG: predicate pruning for shardId 290006
DEBUG: predicate pruning for shardId 290007
sum | avg
-----+-----
|
@ -165,35 +144,46 @@ INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename,
GROUP BY nodename, nodeport
ORDER BY nodename, nodeport ASC
LIMIT 1;
-- Verify that shard pruning works. Note that these queries should all prune
-- one shard.
EXPLAIN SELECT count(*) FROM varchar_partitioned_table WHERE varchar_column = 'BA2';
DEBUG: predicate pruning for shardId 100
QUERY PLAN
-----------------------------------------------------------------------
Aggregate (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
explain statements for distributed queries are not enabled
(3 rows)
-- Verify that shard pruning works. Note that these queries should all
-- prune one shard (see task count). As these tables don't exist
-- remotely, temporarily disable WARNING messages.
SET client_min_messages TO ERROR;
EXPLAIN (COSTS OFF)
SELECT count(*) FROM varchar_partitioned_table WHERE varchar_column = 'BA2';
QUERY PLAN
-------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 1
Tasks Shown: All
-> Task
Error: Could not get remote plan.
(6 rows)
EXPLAIN SELECT count(*) FROM array_partitioned_table
EXPLAIN (COSTS OFF)
SELECT count(*) FROM array_partitioned_table
WHERE array_column > '{BA1000U2AMO4ZGX, BZZXSP27F21T6}';
DEBUG: predicate pruning for shardId 102
QUERY PLAN
-----------------------------------------------------------------------
Aggregate (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
explain statements for distributed queries are not enabled
(3 rows)
QUERY PLAN
-------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 1
Tasks Shown: All
-> Task
Error: Could not get remote plan.
(6 rows)
EXPLAIN SELECT count(*) FROM composite_partitioned_table
EXPLAIN (COSTS OFF)
SELECT count(*) FROM composite_partitioned_table
WHERE composite_column < '(b,5,c)'::composite_type;
DEBUG: predicate pruning for shardId 105
QUERY PLAN
-----------------------------------------------------------------------
Aggregate (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
explain statements for distributed queries are not enabled
(3 rows)
QUERY PLAN
-------------------------------------------------
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 1
Tasks Shown: All
-> Task
Error: Could not get remote plan.
(6 rows)
SET client_min_messages TO NOTICE;

View File

@ -126,7 +126,6 @@ DEBUG: Plan is router executable
-- single-shard tests
-- test simple select for a single row
SELECT * FROM articles_hash WHERE author_id = 10 AND id = 50;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -136,7 +135,6 @@ DEBUG: Plan is router executable
-- get all titles by a single author
SELECT title FROM articles_hash WHERE author_id = 10;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
title
@ -152,7 +150,6 @@ DEBUG: Plan is router executable
SELECT title, word_count FROM articles_hash
WHERE author_id = 10
ORDER BY word_count DESC NULLS LAST;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | word_count
@ -169,7 +166,6 @@ SELECT title, id FROM articles_hash
WHERE author_id = 5
ORDER BY id
LIMIT 2;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | id
@ -183,7 +179,6 @@ DEBUG: Plan is router executable
SELECT title, author_id FROM articles_hash
WHERE author_id = 7 OR author_id = 8
ORDER BY author_id ASC, id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | author_id
@ -203,7 +198,6 @@ DEBUG: Plan is router executable
-- same query is router executable with no order by
SELECT title, author_id FROM articles_hash
WHERE author_id = 7 OR author_id = 8;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
title | author_id
@ -227,7 +221,6 @@ SELECT author_id, sum(word_count) AS corpus_size FROM articles_hash
GROUP BY author_id
HAVING sum(word_count) > 1000
ORDER BY sum(word_count) DESC;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
author_id | corpus_size
@ -244,7 +237,6 @@ SELECT author_id, sum(word_count) AS corpus_size FROM articles_hash
GROUP BY author_id
HAVING sum(word_count) > 1000
ORDER BY sum(word_count) DESC;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
author_id | corpus_size
@ -286,7 +278,6 @@ HINT: Consider rewriting the expression with OR/AND clauses.
-- queries with CTEs are supported
WITH first_author AS ( SELECT id FROM articles_hash WHERE author_id = 1)
SELECT * FROM first_author;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -301,7 +292,6 @@ DEBUG: Plan is router executable
-- queries with CTEs are supported even if CTE is not referenced inside query
WITH first_author AS ( SELECT id FROM articles_hash WHERE author_id = 1)
SELECT title FROM articles_hash WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
title
@ -317,8 +307,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash WHERE author_id = 1)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | id | title
@ -333,8 +321,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash WHERE author_id = 3)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | id | title
@ -345,8 +331,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash WHERE author_id = 2)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840000
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
-- recursive CTEs are supported when filtered on partition column
@ -399,12 +383,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 1))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: Creating router plan
DEBUG: Plan is router executable
company_id | employee_id | manager_id | level
@ -426,9 +404,6 @@ WITH RECURSIVE hierarchy as (
ON (h.employee_id = ce.manager_id AND
h.company_id = ce.company_id))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
-- logically wrong query, query involves different shards
@ -444,12 +419,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 2))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 840004
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: predicate pruning for shardId 840004
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
-- CTE with queries other than SELECT is not supported
@ -485,7 +454,6 @@ SELECT
FROM articles_hash
WHERE author_id = 1 or author_id = 3
GROUP BY GROUPING SETS ((id),(subtitle));
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | subtitle | count
@ -520,7 +488,6 @@ ERROR: could not run distributed query with GROUPING SETS, CUBE, or ROLLUP
HINT: Consider using an equality filter on the distributed table's partition column.
-- queries which involve functions in FROM clause are supported if it goes to a single worker.
SELECT * FROM articles_hash, position('om' in 'Thomas') WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | position
@ -533,7 +500,6 @@ DEBUG: Plan is router executable
(5 rows)
SELECT * FROM articles_hash, position('om' in 'Thomas') WHERE author_id = 1 or author_id = 3;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | position
@ -567,8 +533,6 @@ HINT: Consider using an equality filter on the distributed table's partition co
SELECT * FROM articles_hash
WHERE author_id IN (SELECT author_id FROM articles_hash WHERE author_id = 2)
ORDER BY articles_hash.id;
DEBUG: predicate pruning for shardId 840000
DEBUG: predicate pruning for shardId 840000
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -618,8 +582,6 @@ SELECT articles_hash.id,test.word_count
FROM articles_hash, (SELECT id, word_count FROM articles_hash) AS test
WHERE test.id = articles_hash.id and articles_hash.author_id = 1
ORDER BY articles_hash.id;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: join prunable for task partitionId 0 and 1
DEBUG: join prunable for task partitionId 0 and 2
DEBUG: join prunable for task partitionId 0 and 3
@ -659,7 +621,6 @@ HINT: Consider using an equality filter on the distributed table's partition co
SELECT *
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -675,7 +636,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE author_id = 1 OR author_id = 17;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -705,7 +665,6 @@ SELECT *
SELECT id as article_id, word_count * id as random_value
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
article_id | random_value
@ -722,8 +681,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash a, articles_hash b
WHERE a.author_id = 10 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -739,7 +696,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash a, articles_single_shard_hash b
WHERE a.author_id = 10 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -758,7 +714,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash a, single_shard b
WHERE a.author_id = 2 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 840000
DEBUG: Found no worker with all shard placements
ERROR: could not run distributed query with complex table expressions
HINT: Consider using an equality filter on the distributed table's partition column.
@ -767,7 +722,6 @@ SELECT *
FROM articles_hash
WHERE author_id = 1
LIMIT 3;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -783,7 +737,6 @@ SELECT *
WHERE author_id = 1
LIMIT 2
OFFSET 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -799,7 +752,6 @@ SELECT *
ORDER BY id desc
LIMIT 2
OFFSET 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -815,7 +767,6 @@ SELECT id
WHERE author_id = 1
GROUP BY id
ORDER BY id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -832,7 +783,6 @@ SELECT DISTINCT id
FROM articles_hash
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -848,7 +798,6 @@ DEBUG: Plan is router executable
SELECT avg(word_count)
FROM articles_hash
WHERE author_id = 2;
DEBUG: predicate pruning for shardId 840000
DEBUG: Creating router plan
DEBUG: Plan is router executable
avg
@ -861,7 +810,6 @@ SELECT max(word_count) as max, min(word_count) as min,
sum(word_count) as sum, count(word_count) as cnt
FROM articles_hash
WHERE author_id = 2;
DEBUG: predicate pruning for shardId 840000
DEBUG: Creating router plan
DEBUG: Plan is router executable
max | min | sum | cnt
@ -874,7 +822,6 @@ SELECT max(word_count)
FROM articles_hash
WHERE author_id = 1
GROUP BY author_id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
max
@ -887,8 +834,6 @@ DEBUG: Plan is router executable
(SELECT * FROM articles_hash WHERE author_id = 1)
UNION
(SELECT * FROM articles_hash WHERE author_id = 3);
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -909,8 +854,6 @@ SELECT * FROM (
(SELECT * FROM articles_hash WHERE author_id = 1)
UNION
(SELECT * FROM articles_hash WHERE author_id = 3)) uu;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -930,8 +873,6 @@ DEBUG: Plan is router executable
(SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 1)
UNION
(SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 3);
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
left
@ -942,8 +883,6 @@ DEBUG: Plan is router executable
(SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 1)
INTERSECT
(SELECT LEFT(title, 1) FROM articles_hash WHERE author_id = 3);
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
left
@ -954,8 +893,6 @@ DEBUG: Plan is router executable
(SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 1)
EXCEPT
(SELECT LEFT(title, 2) FROM articles_hash WHERE author_id = 3);
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
left
@ -1019,7 +956,6 @@ SET client_min_messages to 'DEBUG2';
SELECT *
FROM articles_hash
WHERE author_id = 1 and author_id >= 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1049,7 +985,6 @@ SELECT *
SELECT *
FROM articles_hash
WHERE author_id = 1 and (id = 1 or id = 41);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1062,7 +997,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE author_id = 1 and (id = random()::int * 0);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1100,7 +1034,6 @@ SELECT *
SELECT *
FROM articles_hash
WHERE author_id = abs(-1);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1142,7 +1075,6 @@ SELECT *
SELECT *
FROM articles_hash
WHERE author_id = 1 and (id = abs(id - 2));
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1167,7 +1099,6 @@ SELECT *
SELECT *
FROM articles_hash
WHERE (author_id = 1) = true;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1183,7 +1114,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE (author_id = 1) and id between 0 and 20;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1196,7 +1126,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE (author_id = 1) and (id = 1 or id = 31) and title like '%s';
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1209,7 +1138,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE (id = 1 or id = 31) and title like '%s' and (author_id = 1);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1222,7 +1150,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE (title like '%s' or title like 'a%') and (author_id = 1);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1238,7 +1165,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles_hash
WHERE (title like '%s' or title like 'a%') and (author_id = 1) and (word_count < 3000 or word_count > 8000);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1252,7 +1178,6 @@ DEBUG: Plan is router executable
SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
FROM articles_hash
WHERE author_id = 5;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
prev | title | word_count
@ -1268,7 +1193,6 @@ SELECT LAG(title, 1) over (ORDER BY word_count) prev, title, word_count
FROM articles_hash
WHERE author_id = 5
ORDER BY word_count DESC;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
prev | title | word_count
@ -1283,7 +1207,6 @@ DEBUG: Plan is router executable
SELECT id, MIN(id) over (order by word_count)
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | min
@ -1298,7 +1221,6 @@ DEBUG: Plan is router executable
SELECT id, word_count, AVG(word_count) over (order by word_count)
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | word_count | avg
@ -1313,7 +1235,6 @@ DEBUG: Plan is router executable
SELECT word_count, rank() OVER (PARTITION BY author_id ORDER BY word_count)
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
word_count | rank
@ -1404,7 +1325,6 @@ DEBUG: Plan is router executable
SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles_hash a, articles_single_shard_hash b
WHERE a.author_id = 10 and a.author_id = b.author_id and int4eq(1, 1);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -1471,7 +1391,6 @@ DEBUG: Plan is router executable
(SELECT * FROM articles_hash WHERE author_id = 1)
UNION
(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1486,7 +1405,6 @@ DEBUG: Plan is router executable
(SELECT * FROM articles_hash WHERE author_id = 1)
EXCEPT
(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1501,7 +1419,6 @@ DEBUG: Plan is router executable
(SELECT * FROM articles_hash WHERE author_id = 1)
INTERSECT
(SELECT * FROM articles_hash WHERE author_id = 2 and 1=0);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1512,7 +1429,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash WHERE author_id = 1 and 1=0)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | id | title
@ -1522,8 +1438,6 @@ DEBUG: Plan is router executable
WITH id_author AS ( SELECT id, author_id FROM articles_hash WHERE author_id = 1),
id_title AS (SELECT id, title from articles_hash WHERE author_id = 1)
SELECT * FROM id_author, id_title WHERE id_author.id = id_title.id and 1=0;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | id | title
@ -1541,12 +1455,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 1))
SELECT * FROM hierarchy WHERE LEVEL <= 2 and 1=0;
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: Creating router plan
DEBUG: Plan is router executable
company_id | employee_id | manager_id | level
@ -1564,9 +1472,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 1 AND 1=0))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: Creating router plan
DEBUG: Plan is router executable
company_id | employee_id | manager_id | level
@ -1585,9 +1490,6 @@ WITH RECURSIVE hierarchy as (
h.company_id = ce.company_id AND
ce.company_id = 1))
SELECT * FROM hierarchy WHERE LEVEL <= 2;
DEBUG: predicate pruning for shardId 840005
DEBUG: predicate pruning for shardId 840006
DEBUG: predicate pruning for shardId 840007
DEBUG: Creating router plan
DEBUG: Plan is router executable
company_id | employee_id | manager_id | level
@ -1665,9 +1567,6 @@ SELECT master_create_empty_shard('articles_range') as shard_id \gset
UPDATE pg_dist_shard SET shardminvalue = 31, shardmaxvalue=40 WHERE shardid = :shard_id;
-- single shard select queries are router plannable
SELECT * FROM articles_range where author_id = 1;
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1675,9 +1574,6 @@ DEBUG: Plan is router executable
(0 rows)
SELECT * FROM articles_range where author_id = 1 or author_id = 5;
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -1695,12 +1591,6 @@ DEBUG: Plan is router executable
-- single shard joins on range partitioned table are router plannable
SELECT * FROM articles_range ar join authors_range au on (ar.author_id = au.id)
WHERE ar.author_id = 1;
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: predicate pruning for shardId 840009
DEBUG: predicate pruning for shardId 840010
DEBUG: predicate pruning for shardId 840011
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | name | id
@ -1719,10 +1609,6 @@ DEBUG: Plan is router executable
-- multi-shard join is not router plannable
SELECT * FROM articles_range ar join authors_range au on (ar.author_id = au.id)
WHERE ar.author_id = 35;
DEBUG: predicate pruning for shardId 840012
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840012
DEBUG: predicate pruning for shardId 840013
DEBUG: join prunable for intervals [21,40] and [1,10]
DEBUG: join prunable for intervals [31,40] and [1,10]
DEBUG: join prunable for intervals [31,40] and [11,30]
@ -1748,12 +1634,6 @@ DEBUG: join prunable for intervals [31,40] and [11,30]
-- bogus query, join on non-partition column, but router plannable due to filters
SELECT * FROM articles_range ar join authors_range au on (ar.id = au.id)
WHERE ar.author_id = 1 and au.id < 10;
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: predicate pruning for shardId 840009
DEBUG: predicate pruning for shardId 840010
DEBUG: predicate pruning for shardId 840011
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | name | id
@ -1766,10 +1646,6 @@ DEBUG: Plan is router executable
-- router plannable
SELECT * FROM articles_hash ar join authors_range au on (ar.author_id = au.id)
WHERE ar.author_id = 2;
DEBUG: predicate pruning for shardId 840000
DEBUG: predicate pruning for shardId 840009
DEBUG: predicate pruning for shardId 840010
DEBUG: predicate pruning for shardId 840011
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | name | id
@ -1779,12 +1655,7 @@ DEBUG: Plan is router executable
-- not router plannable
SELECT * FROM articles_hash ar join authors_range au on (ar.author_id = au.id)
WHERE ar.author_id = 3;
DEBUG: predicate pruning for shardId 840001
DEBUG: predicate pruning for shardId 840009
DEBUG: predicate pruning for shardId 840010
DEBUG: predicate pruning for shardId 840011
DEBUG: Found no worker with all shard placements
DEBUG: predicate pruning for shardId 840001
DEBUG: join prunable for intervals [1,10] and [11,30]
DEBUG: join prunable for intervals [1,10] and [21,40]
DEBUG: join prunable for intervals [1,10] and [31,40]
@ -1814,9 +1685,6 @@ HINT: Set citus.task_executor_type to "task-tracker".
-- join between a range partitioned table and reference table is router plannable
SELECT * FROM articles_range ar join authors_reference au on (ar.author_id = au.id)
WHERE ar.author_id = 1;
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | name | id
@ -1826,9 +1694,6 @@ DEBUG: Plan is router executable
-- still hits a single shard and router plannable
SELECT * FROM articles_range ar join authors_reference au on (ar.author_id = au.id)
WHERE ar.author_id = 1 or ar.author_id = 5;
DEBUG: predicate pruning for shardId 840013
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count | name | id
@ -1838,10 +1703,6 @@ DEBUG: Plan is router executable
-- it is not router plannable if hit multiple shards
SELECT * FROM articles_range ar join authors_reference au on (ar.author_id = au.id)
WHERE ar.author_id = 1 or ar.author_id = 15;
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
DEBUG: predicate pruning for shardId 840014
DEBUG: predicate pruning for shardId 840015
id | author_id | title | word_count | name | id
----+-----------+-------+------------+------+----
(0 rows)
@ -1907,7 +1768,6 @@ SELECT author_id FROM articles_hash
ORDER BY
author_id
LIMIT 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
WARNING: relation "public.articles_hash" does not exist
@ -1945,7 +1805,6 @@ SELECT * FROM articles_hash
ORDER BY
author_id, id
LIMIT 5;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
WARNING: relation "public.articles_hash" does not exist
@ -1969,7 +1828,6 @@ SELECT
articles_hash
WHERE
author_id = 5;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
c
@ -2011,7 +1869,6 @@ SELECT *
FROM articles_hash
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -2031,7 +1888,6 @@ SELECT *
FROM articles_hash
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -2051,7 +1907,6 @@ DECLARE test_cursor CURSOR FOR
FROM articles_hash
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
FETCH test_cursor;
@ -2087,7 +1942,6 @@ COPY (
FROM articles_hash
WHERE author_id = 1
ORDER BY id) TO STDOUT;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
1 1 arsenous 9572
@ -2102,14 +1956,12 @@ CREATE TEMP TABLE temp_articles_hash as
FROM articles_hash
WHERE author_id = 1
ORDER BY id;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
-- router plannable queries may include filter for aggragates
SELECT count(*), count(*) FILTER (WHERE id < 3)
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
count | count
@ -2132,7 +1984,6 @@ PREPARE author_1_articles as
FROM articles_hash
WHERE author_id = 1;
EXECUTE author_1_articles;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -2150,7 +2001,6 @@ PREPARE author_articles(int) as
FROM articles_hash
WHERE author_id = $1;
EXECUTE author_articles(1);
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -2174,18 +2024,6 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
SELECT author_articles_max_id();
DEBUG: predicate pruning for shardId 840001
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash ah
WHERE author_id = 1"
PL/pgSQL function author_articles_max_id() line 5 at SQL statement
DEBUG: predicate pruning for shardId 840001
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash ah
WHERE author_id = 1"
PL/pgSQL function author_articles_max_id() line 5 at SQL statement
DEBUG: predicate pruning for shardId 840001
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash ah
WHERE author_id = 1"
PL/pgSQL function author_articles_max_id() line 5 at SQL statement
DEBUG: Creating router plan
CONTEXT: SQL statement "SELECT MAX(id) FROM articles_hash ah
WHERE author_id = 1"
@ -2211,11 +2049,6 @@ BEGIN
END;
$$ LANGUAGE plpgsql;
SELECT * FROM author_articles_id_word_count();
DEBUG: predicate pruning for shardId 840001
CONTEXT: SQL statement "SELECT ah.id, ah.word_count
FROM articles_hash ah
WHERE author_id = 1"
PL/pgSQL function author_articles_id_word_count() line 4 at RETURN QUERY
DEBUG: Creating router plan
CONTEXT: SQL statement "SELECT ah.id, ah.word_count
FROM articles_hash ah
@ -2238,7 +2071,6 @@ PL/pgSQL function author_articles_id_word_count() line 4 at RETURN QUERY
-- materialized views can be created for router plannable queries
CREATE MATERIALIZED VIEW mv_articles_hash_empty AS
SELECT * FROM articles_hash WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
SELECT * FROM mv_articles_hash_empty;
@ -2277,7 +2109,6 @@ SET citus.task_executor_type to 'task-tracker';
SELECT id
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -2297,7 +2128,6 @@ DEBUG: Plan is router executable
SELECT id
FROM articles_hash
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 840001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id

View File

@ -129,9 +129,6 @@ SELECT count(*) FROM multi_shard_modify_test;
-- Check that shard pruning works
SET client_min_messages TO DEBUG2;
SELECT master_modify_multiple_shards('DELETE FROM multi_shard_modify_test WHERE t_key = 15');
DEBUG: predicate pruning for shardId 350001
DEBUG: predicate pruning for shardId 350002
DEBUG: predicate pruning for shardId 350003
master_modify_multiple_shards
-------------------------------
1

View File

@ -385,7 +385,6 @@ SET citus.task_executor_type TO 'real-time';
SELECT *
FROM articles
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -401,7 +400,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles
WHERE author_id = 1 OR author_id = 17;
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -430,7 +428,6 @@ SELECT *
SELECT id as article_id, word_count * id as random_value
FROM articles
WHERE author_id = 1;
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
article_id | random_value
@ -448,8 +445,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles a, articles b
WHERE a.author_id = 10 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 850001
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -465,7 +460,6 @@ SELECT a.author_id as first_author, b.word_count as second_word_count
FROM articles a, articles_single_shard b
WHERE a.author_id = 10 and a.author_id = b.author_id
LIMIT 3;
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
first_author | second_word_count
@ -480,7 +474,6 @@ SELECT *
FROM articles
WHERE author_id = 1
LIMIT 2;
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id | author_id | title | word_count
@ -497,7 +490,6 @@ SELECT id
WHERE author_id = 1
GROUP BY id
ORDER BY id;
DEBUG: predicate pruning for shardId 850001
DEBUG: Creating router plan
DEBUG: Plan is router executable
id
@ -518,7 +510,6 @@ DEBUG: Plan is router executable
SELECT avg(word_count)
FROM articles
WHERE author_id = 2;
DEBUG: predicate pruning for shardId 850000
DEBUG: Creating router plan
DEBUG: Plan is router executable
avg
@ -532,7 +523,6 @@ SELECT max(word_count) as max, min(word_count) as min,
sum(word_count) as sum, count(word_count) as cnt
FROM articles
WHERE author_id = 2;
DEBUG: predicate pruning for shardId 850000
DEBUG: Creating router plan
DEBUG: Plan is router executable
max | min | sum | cnt
@ -544,8 +534,6 @@ DEBUG: Plan is router executable
SELECT *
FROM articles a, articles b
WHERE a.id = b.id AND a.author_id = 1;
DEBUG: predicate pruning for shardId 850001
DEBUG: predicate pruning for shardId 850001
DEBUG: join prunable for task partitionId 0 and 1
DEBUG: join prunable for task partitionId 0 and 2
DEBUG: join prunable for task partitionId 0 and 3

View File

@ -339,43 +339,43 @@ SELECT master_create_worker_shards('subquery_pruning_varchar_test_table', 4, 1);
SET citus.subquery_pushdown TO TRUE;
SET client_min_messages TO DEBUG2;
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a)
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a)
AS foo;
SELECT * FROM
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE 'eren' = a GROUP BY a)
AS foo;
SET client_min_messages TO NOTICE;
-- test subquery join on VARCHAR partition column
-- test subquery join on VARCHAR partition column
SELECT * FROM
(SELECT
(SELECT
a_inner AS a
FROM
(SELECT
(SELECT
subquery_pruning_varchar_test_table.a AS a_inner
FROM
FROM
subquery_pruning_varchar_test_table
GROUP BY
GROUP BY
subquery_pruning_varchar_test_table.a
HAVING
count(subquery_pruning_varchar_test_table.a) < 3)
HAVING
count(subquery_pruning_varchar_test_table.a) < 3)
AS f1,
(SELECT
(SELECT
subquery_pruning_varchar_test_table.a
FROM
FROM
subquery_pruning_varchar_test_table
GROUP BY
GROUP BY
subquery_pruning_varchar_test_table.a
HAVING
sum(coalesce(subquery_pruning_varchar_test_table.b,0)) > 20.0)
HAVING
sum(coalesce(subquery_pruning_varchar_test_table.b,0)) > 20.0)
AS f2
WHERE
WHERE
f1.a_inner = f2.a
GROUP BY
GROUP BY
a_inner)
AS foo;
@ -702,7 +702,8 @@ LIMIT
-- Same queries above with explain
-- Simple join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average
FROM
(SELECT
@ -729,7 +730,8 @@ FROM
user_id) AS subquery;
-- Union and left join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average,
hasdone
FROM
@ -793,7 +795,8 @@ GROUP BY
hasdone;
-- Union, left join and having subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average,
count_pay
FROM (
@ -865,7 +868,8 @@ ORDER BY
count_pay;
-- Lateral join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
tenant_id,
user_id,
user_lastseen,

View File

@ -34,7 +34,6 @@ test: multi_average_expression multi_working_columns
test: multi_array_agg
test: multi_agg_type_conversion multi_count_type_conversion
test: multi_hash_pruning
test: multi_null_minmax_value_pruning
test: multi_query_directory_cleanup
test: multi_utility_statements
test: multi_dropped_column_aliases
@ -50,7 +49,6 @@ test: multi_tpch_query7 multi_tpch_query7_nested
# Parallel tests to check our join order planning logic. Note that we load data
# below; and therefore these tests should come after the execution tests.
# ----------
test: multi_join_order_additional
test: multi_load_more_data
test: multi_join_order_tpch_large

View File

@ -373,53 +373,47 @@ SELECT master_create_worker_shards('subquery_pruning_varchar_test_table', 4, 1);
SET citus.subquery_pushdown TO TRUE;
SET client_min_messages TO DEBUG2;
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a)
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a)
AS foo;
DEBUG: predicate pruning for shardId 270005
DEBUG: predicate pruning for shardId 270006
DEBUG: predicate pruning for shardId 270008
count
-------
(0 rows)
SELECT * FROM
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE 'eren' = a GROUP BY a)
AS foo;
DEBUG: predicate pruning for shardId 270005
DEBUG: predicate pruning for shardId 270007
DEBUG: predicate pruning for shardId 270008
count
-------
(0 rows)
SET client_min_messages TO NOTICE;
-- test subquery join on VARCHAR partition column
-- test subquery join on VARCHAR partition column
SELECT * FROM
(SELECT
(SELECT
a_inner AS a
FROM
(SELECT
(SELECT
subquery_pruning_varchar_test_table.a AS a_inner
FROM
FROM
subquery_pruning_varchar_test_table
GROUP BY
GROUP BY
subquery_pruning_varchar_test_table.a
HAVING
count(subquery_pruning_varchar_test_table.a) < 3)
HAVING
count(subquery_pruning_varchar_test_table.a) < 3)
AS f1,
(SELECT
(SELECT
subquery_pruning_varchar_test_table.a
FROM
FROM
subquery_pruning_varchar_test_table
GROUP BY
GROUP BY
subquery_pruning_varchar_test_table.a
HAVING
sum(coalesce(subquery_pruning_varchar_test_table.b,0)) > 20.0)
HAVING
sum(coalesce(subquery_pruning_varchar_test_table.b,0)) > 20.0)
AS f2
WHERE
WHERE
f1.a_inner = f2.a
GROUP BY
GROUP BY
a_inner)
AS foo;
a
@ -738,7 +732,8 @@ LIMIT
-- Same queries above with explain
-- Simple join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average
FROM
(SELECT
@ -765,29 +760,30 @@ FROM
user_id) AS subquery;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: One of 2
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate (cost=40.01..40.02 rows=1 width=16)
-> GroupAggregate (cost=39.89..39.99 rows=1 width=48)
-> Aggregate
-> GroupAggregate
Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Merge Join (cost=39.89..39.97 rows=1 width=540)
-> Merge Join
Merge Cond: ((((users.composite_id).tenant_id) = ((events.composite_id).tenant_id)) AND (((users.composite_id).user_id) = ((events.composite_id).user_id)))
-> Sort (cost=28.08..28.09 rows=6 width=32)
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Seq Scan on users_270013 users (cost=0.00..28.00 rows=6 width=32)
-> Seq Scan on users_270013 users
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Sort (cost=11.81..11.82 rows=3 width=556)
-> Sort
Sort Key: ((events.composite_id).tenant_id), ((events.composite_id).user_id)
-> Seq Scan on events_270009 events (cost=0.00..11.79 rows=3 width=556)
-> Seq Scan on events_270009 events
Filter: ((event_type)::text = ANY ('{click,submit,pay}'::text[]))
(19 rows)
-- Union and left join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average,
hasdone
FROM
@ -851,50 +847,51 @@ GROUP BY
hasdone;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate (cost=0.00..0.00 rows=0 width=0)
HashAggregate
Group Key: remote_scan.hasdone
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: One of 2
-> Task
Node: host=localhost port=57637 dbname=regression
-> GroupAggregate (cost=91.93..91.98 rows=2 width=48)
-> GroupAggregate
Group Key: subquery_top.hasdone
-> Sort (cost=91.93..91.93 rows=2 width=64)
-> Sort
Sort Key: subquery_top.hasdone
-> Subquery Scan on subquery_top (cost=91.85..91.92 rows=2 width=64)
-> GroupAggregate (cost=91.85..91.90 rows=2 width=112)
-> Subquery Scan on subquery_top
-> GroupAggregate
Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id), ('Has done paying'::text)
-> Sort (cost=91.85..91.85 rows=2 width=88)
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id), ('Has done paying'::text)
-> Merge Left Join (cost=91.75..91.84 rows=2 width=88)
-> Merge Left Join
Merge Cond: ((((users.composite_id).tenant_id) = ((events_2.composite_id).tenant_id)) AND (((users.composite_id).user_id) = ((events_2.composite_id).user_id)))
-> Unique (cost=79.46..79.48 rows=2 width=56)
-> Sort (cost=79.46..79.47 rows=2 width=56)
-> Unique
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id), ('action=>1'::text), events.event_time
-> Append (cost=0.00..79.45 rows=2 width=56)
-> Nested Loop (cost=0.00..39.72 rows=1 width=56)
-> Append
-> Nested Loop
Join Filter: (((users.composite_id).tenant_id = (events.composite_id).tenant_id) AND ((users.composite_id).user_id = (events.composite_id).user_id))
-> Seq Scan on events_270009 events (cost=0.00..11.62 rows=1 width=40)
-> Seq Scan on events_270009 events
Filter: ((event_type)::text = 'click'::text)
-> Seq Scan on users_270013 users (cost=0.00..28.00 rows=6 width=32)
-> Seq Scan on users_270013 users
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Nested Loop (cost=0.00..39.72 rows=1 width=56)
-> Nested Loop
Join Filter: (((users_1.composite_id).tenant_id = (events_1.composite_id).tenant_id) AND ((users_1.composite_id).user_id = (events_1.composite_id).user_id))
-> Seq Scan on events_270009 events_1 (cost=0.00..11.62 rows=1 width=40)
-> Seq Scan on events_270009 events_1
Filter: ((event_type)::text = 'submit'::text)
-> Seq Scan on users_270013 users_1 (cost=0.00..28.00 rows=6 width=32)
-> Seq Scan on users_270013 users_1
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Materialize (cost=12.29..12.31 rows=1 width=48)
-> Unique (cost=12.29..12.30 rows=1 width=80)
-> Sort (cost=12.29..12.29 rows=1 width=80)
-> Materialize
-> Unique
-> Sort
Sort Key: ((events_2.composite_id).tenant_id), ((events_2.composite_id).user_id)
-> Seq Scan on events_270009 events_2 (cost=0.00..12.28 rows=1 width=80)
-> Seq Scan on events_270009 events_2
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type) AND ((event_type)::text = 'pay'::text))
(40 rows)
-- Union, left join and having subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average,
count_pay
FROM (
@ -966,7 +963,8 @@ ORDER BY
count_pay;
ERROR: bogus varattno for OUTER_VAR var: 3
-- Lateral join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
tenant_id,
user_id,
user_lastseen,
@ -1017,31 +1015,31 @@ LIMIT
10;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..0.00 rows=0 width=0)
-> Sort (cost=0.00..0.00 rows=0 width=0)
Limit
-> Sort
Sort Key: remote_scan.user_lastseen DESC
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: One of 2
-> Task
Node: host=localhost port=57637 dbname=regression
-> Limit (cost=100.43..100.44 rows=6 width=56)
-> Sort (cost=100.43..100.44 rows=6 width=56)
-> Limit
-> Sort
Sort Key: (max(users.lastseen)) DESC
-> GroupAggregate (cost=100.14..100.29 rows=6 width=56)
-> GroupAggregate
Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Sort (cost=100.14..100.16 rows=6 width=548)
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Nested Loop Left Join (cost=40.04..100.06 rows=6 width=548)
-> Limit (cost=28.08..28.09 rows=6 width=24)
-> Sort (cost=28.08..28.09 rows=6 width=24)
-> Nested Loop Left Join
-> Limit
-> Sort
Sort Key: users.lastseen DESC
-> Seq Scan on users_270013 users (cost=0.00..28.00 rows=6 width=24)
-> Seq Scan on users_270013 users
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Limit (cost=11.96..11.96 rows=1 width=524)
-> Sort (cost=11.96..11.96 rows=1 width=524)
-> Limit
-> Sort
Sort Key: events.event_time DESC
-> Seq Scan on events_270009 events (cost=0.00..11.95 rows=1 width=524)
-> Seq Scan on events_270009 events
Filter: (((composite_id).tenant_id = ((users.composite_id).tenant_id)) AND ((composite_id).user_id = ((users.composite_id).user_id)))
(26 rows)

View File

@ -373,53 +373,47 @@ SELECT master_create_worker_shards('subquery_pruning_varchar_test_table', 4, 1);
SET citus.subquery_pushdown TO TRUE;
SET client_min_messages TO DEBUG2;
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a)
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE a = 'onder' GROUP BY a)
AS foo;
DEBUG: predicate pruning for shardId 270005
DEBUG: predicate pruning for shardId 270006
DEBUG: predicate pruning for shardId 270008
count
-------
(0 rows)
SELECT * FROM
SELECT * FROM
(SELECT count(*) FROM subquery_pruning_varchar_test_table WHERE 'eren' = a GROUP BY a)
AS foo;
DEBUG: predicate pruning for shardId 270005
DEBUG: predicate pruning for shardId 270007
DEBUG: predicate pruning for shardId 270008
count
-------
(0 rows)
SET client_min_messages TO NOTICE;
-- test subquery join on VARCHAR partition column
-- test subquery join on VARCHAR partition column
SELECT * FROM
(SELECT
(SELECT
a_inner AS a
FROM
(SELECT
(SELECT
subquery_pruning_varchar_test_table.a AS a_inner
FROM
FROM
subquery_pruning_varchar_test_table
GROUP BY
GROUP BY
subquery_pruning_varchar_test_table.a
HAVING
count(subquery_pruning_varchar_test_table.a) < 3)
HAVING
count(subquery_pruning_varchar_test_table.a) < 3)
AS f1,
(SELECT
(SELECT
subquery_pruning_varchar_test_table.a
FROM
FROM
subquery_pruning_varchar_test_table
GROUP BY
GROUP BY
subquery_pruning_varchar_test_table.a
HAVING
sum(coalesce(subquery_pruning_varchar_test_table.b,0)) > 20.0)
HAVING
sum(coalesce(subquery_pruning_varchar_test_table.b,0)) > 20.0)
AS f2
WHERE
WHERE
f1.a_inner = f2.a
GROUP BY
GROUP BY
a_inner)
AS foo;
a
@ -738,7 +732,8 @@ LIMIT
-- Same queries above with explain
-- Simple join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average
FROM
(SELECT
@ -765,29 +760,30 @@ FROM
user_id) AS subquery;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Aggregate (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
Aggregate
-> Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: One of 2
-> Task
Node: host=localhost port=57637 dbname=regression
-> Aggregate (cost=40.01..40.02 rows=1 width=32)
-> GroupAggregate (cost=39.89..39.99 rows=1 width=556)
-> Aggregate
-> GroupAggregate
Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Merge Join (cost=39.89..39.97 rows=1 width=556)
-> Merge Join
Merge Cond: ((((users.composite_id).tenant_id) = ((events.composite_id).tenant_id)) AND (((users.composite_id).user_id) = ((events.composite_id).user_id)))
-> Sort (cost=28.08..28.09 rows=6 width=32)
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Seq Scan on users_270013 users (cost=0.00..28.00 rows=6 width=32)
-> Seq Scan on users_270013 users
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Sort (cost=11.81..11.82 rows=3 width=556)
-> Sort
Sort Key: ((events.composite_id).tenant_id), ((events.composite_id).user_id)
-> Seq Scan on events_270009 events (cost=0.00..11.79 rows=3 width=556)
-> Seq Scan on events_270009 events
Filter: ((event_type)::text = ANY ('{click,submit,pay}'::text[]))
(19 rows)
-- Union and left join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average,
hasdone
FROM
@ -851,47 +847,48 @@ GROUP BY
hasdone;
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
HashAggregate (cost=0.00..0.00 rows=0 width=0)
HashAggregate
Group Key: remote_scan.hasdone
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: One of 2
-> Task
Node: host=localhost port=57637 dbname=regression
-> HashAggregate (cost=91.94..91.96 rows=2 width=64)
-> HashAggregate
Group Key: COALESCE(('Has done paying'::text), 'Has not done paying'::text)
-> GroupAggregate (cost=91.85..91.90 rows=2 width=88)
-> GroupAggregate
Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id), ('Has done paying'::text)
-> Sort (cost=91.85..91.85 rows=2 width=88)
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id), ('Has done paying'::text)
-> Merge Left Join (cost=91.75..91.84 rows=2 width=88)
-> Merge Left Join
Merge Cond: ((((users.composite_id).tenant_id) = ((events_2.composite_id).tenant_id)) AND (((users.composite_id).user_id) = ((events_2.composite_id).user_id)))
-> Unique (cost=79.46..79.48 rows=2 width=40)
-> Sort (cost=79.46..79.47 rows=2 width=40)
-> Unique
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id), ('action=>1'::text), events.event_time
-> Append (cost=0.00..79.45 rows=2 width=40)
-> Nested Loop (cost=0.00..39.72 rows=1 width=40)
-> Append
-> Nested Loop
Join Filter: (((users.composite_id).tenant_id = (events.composite_id).tenant_id) AND ((users.composite_id).user_id = (events.composite_id).user_id))
-> Seq Scan on events_270009 events (cost=0.00..11.62 rows=1 width=40)
-> Seq Scan on events_270009 events
Filter: ((event_type)::text = 'click'::text)
-> Seq Scan on users_270013 users (cost=0.00..28.00 rows=6 width=32)
-> Seq Scan on users_270013 users
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Nested Loop (cost=0.00..39.72 rows=1 width=40)
-> Nested Loop
Join Filter: (((users_1.composite_id).tenant_id = (events_1.composite_id).tenant_id) AND ((users_1.composite_id).user_id = (events_1.composite_id).user_id))
-> Seq Scan on events_270009 events_1 (cost=0.00..11.62 rows=1 width=40)
-> Seq Scan on events_270009 events_1
Filter: ((event_type)::text = 'submit'::text)
-> Seq Scan on users_270013 users_1 (cost=0.00..28.00 rows=6 width=32)
-> Seq Scan on users_270013 users_1
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Materialize (cost=12.29..12.31 rows=1 width=48)
-> Unique (cost=12.29..12.30 rows=1 width=32)
-> Sort (cost=12.29..12.29 rows=1 width=32)
-> Materialize
-> Unique
-> Sort
Sort Key: ((events_2.composite_id).tenant_id), ((events_2.composite_id).user_id)
-> Seq Scan on events_270009 events_2 (cost=0.00..12.28 rows=1 width=32)
-> Seq Scan on events_270009 events_2
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type) AND ((event_type)::text = 'pay'::text))
(37 rows)
-- Union, left join and having subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
avg(array_length(events, 1)) AS event_average,
count_pay
FROM (
@ -963,7 +960,8 @@ ORDER BY
count_pay;
ERROR: bogus varattno for OUTER_VAR var: 3
-- Lateral join subquery pushdown
EXPLAIN SELECT
EXPLAIN (COSTS OFF)
SELECT
tenant_id,
user_id,
user_lastseen,
@ -1014,31 +1012,31 @@ LIMIT
10;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Limit (cost=0.00..0.00 rows=0 width=0)
-> Sort (cost=0.00..0.00 rows=0 width=0)
Limit
-> Sort
Sort Key: remote_scan.user_lastseen DESC
-> Custom Scan (Citus Real-Time) (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Real-Time)
Task Count: 2
Tasks Shown: One of 2
-> Task
Node: host=localhost port=57637 dbname=regression
-> Limit (cost=100.43..100.44 rows=6 width=56)
-> Sort (cost=100.43..100.44 rows=6 width=56)
-> Limit
-> Sort
Sort Key: (max(users.lastseen)) DESC
-> GroupAggregate (cost=100.14..100.29 rows=6 width=548)
-> GroupAggregate
Group Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Sort (cost=100.14..100.16 rows=6 width=548)
-> Sort
Sort Key: ((users.composite_id).tenant_id), ((users.composite_id).user_id)
-> Nested Loop Left Join (cost=40.04..100.06 rows=6 width=548)
-> Limit (cost=28.08..28.09 rows=6 width=40)
-> Sort (cost=28.08..28.09 rows=6 width=40)
-> Nested Loop Left Join
-> Limit
-> Sort
Sort Key: users.lastseen DESC
-> Seq Scan on users_270013 users (cost=0.00..28.00 rows=6 width=40)
-> Seq Scan on users_270013 users
Filter: ((composite_id >= '(1,-9223372036854775808)'::user_composite_type) AND (composite_id <= '(1,9223372036854775807)'::user_composite_type))
-> Limit (cost=11.96..11.96 rows=1 width=524)
-> Sort (cost=11.96..11.96 rows=1 width=524)
-> Limit
-> Sort
Sort Key: events.event_time DESC
-> Seq Scan on events_270009 events (cost=0.00..11.95 rows=1 width=524)
-> Seq Scan on events_270009 events
Filter: (((composite_id).tenant_id = ((users.composite_id).tenant_id)) AND ((composite_id).user_id = ((users.composite_id).user_id)))
(26 rows)

View File

@ -14,7 +14,13 @@ SET client_min_messages TO DEBUG2;
SET citus.task_executor_type TO 'task-tracker';
-- Single range-repartition join to test join-pruning behaviour.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
orders, customer
WHERE
o_custkey = c_custkey;
SELECT
count(*)
FROM
@ -24,7 +30,14 @@ WHERE
-- Single range-repartition join with a selection clause on the partitioned
-- table to test the case when all map tasks are pruned away.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
orders, customer
WHERE
o_custkey = c_custkey AND
o_orderkey < 0;
SELECT
count(*)
FROM
@ -35,7 +48,14 @@ WHERE
-- Single range-repartition join with a selection clause on the base table to
-- test the case when all sql tasks are pruned away.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
orders, customer
WHERE
o_custkey = c_custkey AND
c_custkey < 0;
SELECT
count(*)
FROM
@ -47,7 +67,13 @@ WHERE
-- Dual hash-repartition join test case. Note that this query doesn't produce
-- meaningful results and is only to test hash-partitioning of two large tables
-- on non-partition columns.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
lineitem, customer
WHERE
l_partkey = c_nationkey;
SELECT
count(*)
FROM
@ -57,7 +83,14 @@ WHERE
-- Dual hash-repartition join with a selection clause on one of the tables to
-- test the case when all map tasks are pruned away.
EXPLAIN (COSTS OFF)
SELECT
count(*)
FROM
lineitem, customer
WHERE
l_partkey = c_nationkey AND
l_orderkey < 0;
SELECT
count(*)
FROM
@ -67,6 +100,14 @@ WHERE
l_orderkey < 0;
-- Test cases with false in the WHERE clause
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
orders INNER JOIN customer ON (o_custkey = c_custkey)
WHERE
false;
-- execute once, to verify that's handled
SELECT
o_orderkey
FROM
@ -74,6 +115,7 @@ FROM
WHERE
false;
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
@ -81,11 +123,13 @@ FROM
WHERE
1=0 AND c_custkey < 0;
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM
orders INNER JOIN customer ON (o_custkey = c_custkey AND false);
EXPLAIN (COSTS OFF)
SELECT
o_orderkey
FROM

View File

@ -8,8 +8,11 @@
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 760000;
SET client_min_messages TO DEBUG2;
SET citus.explain_all_tasks TO on;
-- to avoid differing explain output - executor doesn't matter,
-- because were testing pruning here.
SET citus.task_executor_type TO 'real-time';
-- Change configuration to treat lineitem and orders tables as large
@ -20,8 +23,10 @@ SELECT shardminvalue, shardmaxvalue from pg_dist_shard WHERE shardid = 290001;
-- Check that partition and join pruning works when min/max values exist
-- Adding l_orderkey = 1 to make the query not router executable
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030 or l_orderkey = 1;
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
@ -30,8 +35,10 @@ SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
UPDATE pg_dist_shard SET shardminvalue = NULL WHERE shardid = 290000;
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030;
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
@ -40,8 +47,10 @@ SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
UPDATE pg_dist_shard SET shardmaxvalue = NULL WHERE shardid = 290001;
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030;
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;
@ -50,8 +59,10 @@ SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
UPDATE pg_dist_shard SET shardminvalue = '0' WHERE shardid = 290000;
EXPLAIN (COSTS FALSE)
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030;
EXPLAIN (COSTS FALSE)
SELECT sum(l_linenumber), avg(l_linenumber) FROM lineitem, orders
WHERE l_orderkey = o_orderkey;

View File

@ -8,10 +8,6 @@
ALTER SEQUENCE pg_catalog.pg_dist_shardid_seq RESTART 770000;
SET citus.explain_distributed_queries TO off;
SET client_min_messages TO DEBUG2;
-- Adding additional l_orderkey = 1 to make this query not router executable
SELECT l_orderkey, l_linenumber, l_shipdate FROM lineitem WHERE l_orderkey = 9030 or l_orderkey = 1;
@ -131,15 +127,21 @@ INSERT INTO pg_dist_shard_placement (shardid, shardstate, shardlength, nodename,
ORDER BY nodename, nodeport ASC
LIMIT 1;
-- Verify that shard pruning works. Note that these queries should all prune
-- one shard.
-- Verify that shard pruning works. Note that these queries should all
-- prune one shard (see task count). As these tables don't exist
-- remotely, temporarily disable WARNING messages.
SET client_min_messages TO ERROR;
EXPLAIN SELECT count(*) FROM varchar_partitioned_table WHERE varchar_column = 'BA2';
EXPLAIN SELECT count(*) FROM array_partitioned_table
EXPLAIN (COSTS OFF)
SELECT count(*) FROM varchar_partitioned_table WHERE varchar_column = 'BA2';
EXPLAIN (COSTS OFF)
SELECT count(*) FROM array_partitioned_table
WHERE array_column > '{BA1000U2AMO4ZGX, BZZXSP27F21T6}';
EXPLAIN SELECT count(*) FROM composite_partitioned_table
EXPLAIN (COSTS OFF)
SELECT count(*) FROM composite_partitioned_table
WHERE composite_column < '(b,5,c)'::composite_type;
SET client_min_messages TO NOTICE;