mirror of https://github.com/citusdata/citus.git
check query plan during physical planning for outer joins
parent
c2c6f7b910
commit
f1181db55c
|
|
@ -2302,6 +2302,18 @@ QueryPushdownSqlTaskList(Query *query, uint64 jobId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We might fail to find outer joins from the relationRestrictionContext
|
||||||
|
* when the original query has CTEs. In order to ensure that we always mark
|
||||||
|
* the outer joins correctly and compute additional quals when necessary,
|
||||||
|
* check the task query as well.
|
||||||
|
*/
|
||||||
|
if (!updateQualsForOuterJoin && FindNodeMatchingCheckFunction((Node *) query,
|
||||||
|
IsOuterJoinExpr))
|
||||||
|
{
|
||||||
|
updateQualsForOuterJoin = true;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We keep track of minShardOffset to skip over a potentially big amount of pruned
|
* We keep track of minShardOffset to skip over a potentially big amount of pruned
|
||||||
* shards. However, we need to start at minShardOffset - 1 to make sure we don't
|
* shards. However, we need to start at minShardOffset - 1 to make sure we don't
|
||||||
|
|
|
||||||
|
|
@ -845,6 +845,14 @@ DEBUG: assigned task to node localhost:xxxxx
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
|
-- Ensure that even when CTEs are replaced, we insert push
|
||||||
|
-- down conditions for outer joins when necessary.
|
||||||
|
WITH cte_0 AS ( SELECT table_0.a FROM d1 AS table_0 WHERE table_0.a IN ( SELECT table_1.a FROM d1 AS table_1 ORDER BY a LIMIT 2 ) ORDER BY a ) SELECT count(*), avg(avgsub.a) FROM ( SELECT table_2.a FROM cte_0 AS table_2 RIGHT JOIN r1 AS table_3 USING (a)) AS avgsub;
|
||||||
|
count | avg
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
15 | 1.00000000000000000000
|
||||||
|
(1 row)
|
||||||
|
|
||||||
-- The following queries trigger recursive computing, recurring outer-join push down
|
-- The following queries trigger recursive computing, recurring outer-join push down
|
||||||
-- methods introduced in#7973 can be enhanced to cover these cases in the future.
|
-- methods introduced in#7973 can be enhanced to cover these cases in the future.
|
||||||
CREATE TABLE r1_local AS SELECT * FROM r1;
|
CREATE TABLE r1_local AS SELECT * FROM r1;
|
||||||
|
|
|
||||||
|
|
@ -117,6 +117,11 @@ SELECT count(*) FROM (SELECT * FROM d1) AS t1 RIGHT JOIN r1 USING (a);
|
||||||
|
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
|
|
||||||
|
-- Ensure that even when CTEs are replaced, we insert push
|
||||||
|
-- down conditions for outer joins when necessary.
|
||||||
|
WITH cte_0 AS ( SELECT table_0.a FROM d1 AS table_0 WHERE table_0.a IN ( SELECT table_1.a FROM d1 AS table_1 ORDER BY a LIMIT 2 ) ORDER BY a ) SELECT count(*), avg(avgsub.a) FROM ( SELECT table_2.a FROM cte_0 AS table_2 RIGHT JOIN r1 AS table_3 USING (a)) AS avgsub;
|
||||||
|
|
||||||
|
|
||||||
-- The following queries trigger recursive computing, recurring outer-join push down
|
-- The following queries trigger recursive computing, recurring outer-join push down
|
||||||
-- methods introduced in#7973 can be enhanced to cover these cases in the future.
|
-- methods introduced in#7973 can be enhanced to cover these cases in the future.
|
||||||
CREATE TABLE r1_local AS SELECT * FROM r1;
|
CREATE TABLE r1_local AS SELECT * FROM r1;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue