Skip to content

Commit

Permalink
Add forgotten test files
Browse files Browse the repository at this point in the history
9e2f8b6 forgot to contain the .sql and expected/.out files for
hints_anywhere feature. Add them.
  • Loading branch information
horiguti committed Jan 19, 2022
1 parent c23bb6a commit 501fdfc
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
83 changes: 83 additions & 0 deletions expected/hints_anywhere.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
LOAD 'pg_hint_plan';
SET client_min_messages TO log;
\set SHOW_CONTEXT always
SET pg_hint_plan.debug_print TO on;
explain (costs false)
select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
QUERY PLAN
--------------------------------------
Merge Join
Merge Cond: (t1.id = t2.id)
-> Index Scan using t1_pkey on t1
-> Index Scan using t2_pkey on t2
(4 rows)

set pg_hint_plan.hints_anywhere = on;
explain (costs false)
select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
LOG: pg_hint_plan:
used hint:
HashJoin(t1 t2)
not used hint:
duplication hint:
error hint:

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

set pg_hint_plan.hints_anywhere = off;
explain (costs false)
select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';
QUERY PLAN
--------------------------------------
Merge Join
Merge Cond: (t1.id = t2.id)
-> Index Scan using t1_pkey on t1
-> Index Scan using t2_pkey on t2
(4 rows)

set pg_hint_plan.hints_anywhere = on;
/*+ MergeJoin(t1 t2) */
explain (costs false)
select * from t1 join t2 on t1.val = t2.val where '/*+HashJoin(t1 t2)*/' <> '';
LOG: pg_hint_plan:
used hint:
MergeJoin(t1 t2)
not used hint:
duplication hint:
error hint:

QUERY PLAN
-------------------------------------------
Merge Join
Merge Cond: (t2.val = t1.val)
-> Index Scan using t2_val on t2
-> Materialize
-> Index Scan using t1_val on t1
(5 rows)

/*+ HashJoin(t1 t2) */
explain (costs false)
select * from t1 join t2 on t1.val = t2.val where '/*+MergeJoin(t1 t2)*/' <> '';
LOG: pg_hint_plan:
used hint:
HashJoin(t1 t2)
not used hint:
duplication hint:
error hint:

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

24 changes: 24 additions & 0 deletions sql/hints_anywhere.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
LOAD 'pg_hint_plan';
SET client_min_messages TO log;
\set SHOW_CONTEXT always
SET pg_hint_plan.debug_print TO on;

explain (costs false)
select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';

set pg_hint_plan.hints_anywhere = on;
explain (costs false)
select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';

set pg_hint_plan.hints_anywhere = off;
explain (costs false)
select * from t1 join t2 on t1.id = t2.id where '/*+HashJoin(t1 t2)*/' <> '';

set pg_hint_plan.hints_anywhere = on;
/*+ MergeJoin(t1 t2) */
explain (costs false)
select * from t1 join t2 on t1.val = t2.val where '/*+HashJoin(t1 t2)*/' <> '';

/*+ HashJoin(t1 t2) */
explain (costs false)
select * from t1 join t2 on t1.val = t2.val where '/*+MergeJoin(t1 t2)*/' <> '';

0 comments on commit 501fdfc

Please sign in to comment.