Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions expected/ut-J.out
Original file line number Diff line number Diff line change
Expand Up @@ -4775,3 +4775,103 @@ error hint:
-> Seq Scan on t3
(11 rows)

----
---- No. J-4-1 outer join support
----
-- No. J-4-1-1 nested outer join as inner side of join
EXPLAIN (COSTS false) SELECT * FROM s1.t1 JOIN (s1.t2 LEFT JOIN s1.t3 ON t2.c1 = t3.c1) ON t1.c1 = t2.c1;
QUERY PLAN
------------------------------------------
Merge Join
Merge Cond: (t1.c1 = t2.c1)
-> Index Scan using t1_i1 on t1
-> Sort
Sort Key: t2.c1
-> Hash Right Join
Hash Cond: (t3.c1 = t2.c1)
-> Seq Scan on t3
-> Hash
-> Seq Scan on t2
(10 rows)

/*+Leading((t1 (t2 t3))) NestLoop(t1 t2 t3)*/
EXPLAIN (COSTS false) SELECT * FROM s1.t1 JOIN (s1.t2 LEFT JOIN s1.t3 ON t2.c1 = t3.c1) ON t1.c1 = t2.c1;
LOG: pg_hint_plan:
used hint:
NestLoop(t1 t2 t3)
Leading((t1 (t2 t3)))
not used hint:
duplication hint:
error hint:

QUERY PLAN
------------------------------------------
Nested Loop
Join Filter: (t1.c1 = t2.c1)
-> Seq Scan on t1
-> Materialize
-> Hash Left Join
Hash Cond: (t2.c1 = t3.c1)
-> Seq Scan on t2
-> Hash
-> Seq Scan on t3
(9 rows)

-- No. J-4-1-2 SEMI join
EXPLAIN (COSTS false) SELECT * FROM s1.t1 WHERE EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
QUERY PLAN
------------------------------------
Merge Join
Merge Cond: (t1.c1 = t2.c1)
-> Index Scan using t1_i1 on t1
-> Sort
Sort Key: t2.c1
-> Seq Scan on t2
(6 rows)

/*+HashJoin(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM s1.t1 WHERE EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
LOG: pg_hint_plan:
used hint:
HashJoin(t1 t2)
not used hint:
duplication hint:
error hint:

QUERY PLAN
------------------------------
Hash Join
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1
-> Hash
-> Seq Scan on t2
(5 rows)

-- No. J-4-1-3 ANTI join
EXPLAIN (COSTS false) SELECT * FROM s1.t1 WHERE NOT EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
QUERY PLAN
------------------------------
Hash Anti Join
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1
-> Hash
-> Seq Scan on t2
(5 rows)

/*+NestLoop(t1 t2)*/
EXPLAIN (COSTS false) SELECT * FROM s1.t1 WHERE NOT EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
LOG: pg_hint_plan:
used hint:
NestLoop(t1 t2)
not used hint:
duplication hint:
error hint:

QUERY PLAN
-----------------------------------------
Nested Loop Anti Join
-> Seq Scan on t1
-> Index Only Scan using t2_i1 on t2
Index Cond: (c1 = t1.c1)
(4 rows)

262 changes: 262 additions & 0 deletions expected/ut-R.out
Original file line number Diff line number Diff line change
Expand Up @@ -4941,3 +4941,265 @@ error hint:
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(6 rows)

SET client_min_messages TO LOG;
----
---- No. R-4-1 outer join support
----
-- No. R-4-1-1 LEFT JOIN
SELECT explain_filter('
EXPLAIN SELECT * FROM s1.t1 LEFT JOIN s1.t2 ON t1.c1 = t2.c1;
');
explain_filter
----------------------------------------------------------------
Hash Left Join (cost=xxx..xxx rows=1000 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

SELECT explain_filter('
/*+Rows(t1 t2 #1)*/
EXPLAIN SELECT * FROM s1.t1 LEFT JOIN s1.t2 ON t1.c1 = t2.c1;
');
LOG: pg_hint_plan:
used hint:
Rows(t1 t2 #1)
not used hint:
duplication hint:
error hint:

explain_filter
----------------------------------------------------------------
Hash Left Join (cost=xxx..xxx rows=1 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

-- No. R-4-1-2 RIGHT JOIN
SELECT explain_filter('
EXPLAIN SELECT * FROM s1.t1 RIGHT JOIN s1.t2 ON t1.c1 = t2.c1;
');
explain_filter
-------------------------------------------------------------------------
Merge Right Join (cost=xxx..xxx rows=100 width=xxx)
Merge Cond: (t1.c1 = t2.c1)
-> Index Scan using t1_i1 on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Sort (cost=xxx..xxx rows=100 width=xxx)
Sort Key: t2.c1
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(6 rows)

SELECT explain_filter('
/*+Rows(t1 t2 #1)*/
EXPLAIN SELECT * FROM s1.t1 RIGHT JOIN s1.t2 ON t1.c1 = t2.c1;
');
LOG: pg_hint_plan:
used hint:
Rows(t1 t2 #1)
not used hint:
duplication hint:
error hint:

explain_filter
-------------------------------------------------------------------------
Merge Right Join (cost=xxx..xxx rows=1 width=xxx)
Merge Cond: (t1.c1 = t2.c1)
-> Index Scan using t1_i1 on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Sort (cost=xxx..xxx rows=100 width=xxx)
Sort Key: t2.c1
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(6 rows)

-- No. R-4-1-3 FULL JOIN
SELECT explain_filter('
EXPLAIN SELECT * FROM s1.t1 FULL JOIN s1.t2 ON t1.c1 = t2.c1;
');
explain_filter
----------------------------------------------------------------
Hash Full Join (cost=xxx..xxx rows=1000 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

SELECT explain_filter('
/*+Rows(t1 t2 #1)*/
EXPLAIN SELECT * FROM s1.t1 FULL JOIN s1.t2 ON t1.c1 = t2.c1;
');
LOG: pg_hint_plan:
used hint:
Rows(t1 t2 #1)
not used hint:
duplication hint:
error hint:

explain_filter
----------------------------------------------------------------
Hash Full Join (cost=xxx..xxx rows=1 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

-- No. R-4-1-4 nested outer joins
SELECT explain_filter('
EXPLAIN SELECT * FROM s1.t1 LEFT JOIN s1.t2 ON t1.c1 = t2.c1 LEFT JOIN s1.t3 ON t2.c1 = t3.c1;
');
explain_filter
----------------------------------------------------------------------------
Hash Left Join (cost=xxx..xxx rows=1000 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Hash Right Join (cost=xxx..xxx rows=100 width=xxx)
Hash Cond: (t3.c1 = t2.c1)
-> Seq Scan on t3 (cost=xxx..xxx rows=1130 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(9 rows)

SELECT explain_filter('
/*+Rows(t2 t3 #1)*/
EXPLAIN SELECT * FROM s1.t1 LEFT JOIN s1.t2 ON t1.c1 = t2.c1 LEFT JOIN s1.t3 ON t2.c1 = t3.c1;
');
LOG: pg_hint_plan:
used hint:
Rows(t2 t3 #1)
not used hint:
duplication hint:
error hint:

explain_filter
----------------------------------------------------------------------------
Hash Left Join (cost=xxx..xxx rows=1000 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=1 width=xxx)
-> Hash Right Join (cost=xxx..xxx rows=1 width=xxx)
Hash Cond: (t3.c1 = t2.c1)
-> Seq Scan on t3 (cost=xxx..xxx rows=1130 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(9 rows)

----
---- No. R-4-2 SEMI/ANTI join support
----
-- No. R-4-2-1 SEMI join
SELECT explain_filter('
EXPLAIN SELECT * FROM s1.t1 WHERE EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
');
explain_filter
-------------------------------------------------------------------------
Merge Join (cost=xxx..xxx rows=100 width=xxx)
Merge Cond: (t1.c1 = t2.c1)
-> Index Scan using t1_i1 on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Sort (cost=xxx..xxx rows=100 width=xxx)
Sort Key: t2.c1
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(6 rows)

SELECT explain_filter('
/*+Rows(t1 t2 #1)*/
EXPLAIN SELECT * FROM s1.t1 WHERE EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
');
LOG: pg_hint_plan:
used hint:
Rows(t1 t2 #1)
not used hint:
duplication hint:
error hint:

explain_filter
-------------------------------------------------------------------------
Merge Join (cost=xxx..xxx rows=1 width=xxx)
Merge Cond: (t1.c1 = t2.c1)
-> Index Scan using t1_i1 on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Sort (cost=xxx..xxx rows=100 width=xxx)
Sort Key: t2.c1
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(6 rows)

-- No. R-4-2-2 ANTI join
SELECT explain_filter('
EXPLAIN SELECT * FROM s1.t1 WHERE NOT EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
');
explain_filter
----------------------------------------------------------------
Hash Anti Join (cost=xxx..xxx rows=900 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

SELECT explain_filter('
/*+Rows(t1 t2 #1)*/
EXPLAIN SELECT * FROM s1.t1 WHERE NOT EXISTS (SELECT 1 FROM s1.t2 WHERE t1.c1 = t2.c1);
');
LOG: pg_hint_plan:
used hint:
Rows(t1 t2 #1)
not used hint:
duplication hint:
error hint:

explain_filter
----------------------------------------------------------------
Hash Anti Join (cost=xxx..xxx rows=1 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

----
---- No. R-4-3 negative tests
----
-- No. R-4-3-1 hint references non-existent table
SELECT explain_filter('
/*+Rows(t1 t99 #1)*/
EXPLAIN SELECT * FROM s1.t1 LEFT JOIN s1.t2 ON t1.c1 = t2.c1;
');
LOG: pg_hint_plan:
used hint:
not used hint:
Rows(t1 t99 #1)
duplication hint:
error hint:

explain_filter
----------------------------------------------------------------
Hash Left Join (cost=xxx..xxx rows=1000 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

-- No. R-4-3-2 hint references tables not in join
SELECT explain_filter('
/*+Rows(t1 t3 #1)*/
EXPLAIN SELECT * FROM s1.t1 LEFT JOIN s1.t2 ON t1.c1 = t2.c1;
');
LOG: pg_hint_plan:
used hint:
not used hint:
Rows(t1 t3 #1)
duplication hint:
error hint:

explain_filter
----------------------------------------------------------------
Hash Left Join (cost=xxx..xxx rows=1000 width=xxx)
Hash Cond: (t1.c1 = t2.c1)
-> Seq Scan on t1 (cost=xxx..xxx rows=1000 width=xxx)
-> Hash (cost=xxx..xxx rows=100 width=xxx)
-> Seq Scan on t2 (cost=xxx..xxx rows=100 width=xxx)
(5 rows)

Loading