QUERY PLAN
---------------------------------------
Nested Loop
+ Join Filter: (t1.id = t2.id)
-> Seq Scan on t1
Filter: (ctid = '(1,1)'::tid)
- -> Index Scan using t2_pkey on t2
- Index Cond: (id = t1.id)
+ -> Seq Scan on t2
Filter: (ctid = '(1,1)'::tid)
(6 rows)
QUERY PLAN
------------------------------
Hash Full Join
- Hash Cond: (t1.id = t2.id)
- -> Seq Scan on t1
+ Hash Cond: (t2.id = t1.id)
+ -> Seq Scan on t2
-> Hash
- -> Seq Scan on t2
+ -> Seq Scan on t1
(5 rows)
-- inheritance tables test
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Seq Scan on p1
Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+ Index Cond: (id < 10)
+(6 rows)
/*+MergeJoin(p1 t1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Seq Scan on p1
Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+ Index Cond: (id < 10)
+(6 rows)
/*+MergeJoin(p1 t1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Seq Scan on p1
Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+ Index Cond: (id < 10)
+(6 rows)
SET constraint_exclusion TO on;
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Seq Scan on p1
Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+ Index Cond: (id < 10)
+(6 rows)
SET constraint_exclusion TO off;
/*+SeqScan(p1)*/
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Seq Scan on p1
Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+ Index Cond: (id < 10)
+(6 rows)
/*+IndexScan(p1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
duplication hint:
error hint:
- QUERY PLAN
---------------------------------------------------
- Nested Loop
+ QUERY PLAN
+-------------------------------------------------
+ Merge Join
+ Merge Cond: (p1.id = t1.id)
-> Index Scan using p1_pkey on p1
Index Cond: ((id >= 50) AND (id <= 51))
Filter: (ctid = '(1,1)'::tid)
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+ Index Cond: (id < 10)
+(7 rows)
/*+BitmapScan(p1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
QUERY PLAN
-------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Bitmap Heap Scan on p1
Recheck Cond: ((id >= 50) AND (id <= 51))
Filter: (ctid = '(1,1)'::tid)
-> Bitmap Index Scan on p1_pkey
Index Cond: ((id >= 50) AND (id <= 51))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(8 rows)
+ Index Cond: (id < 10)
+(9 rows)
/*+TidScan(p1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
duplication hint:
error hint:
- QUERY PLAN
---------------------------------------------------
+ QUERY PLAN
+---------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Tid Scan on p1
TID Cond: (ctid = '(1,1)'::tid)
Filter: ((id >= 50) AND (id <= 51))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+ Index Cond: (id < 10)
+(7 rows)
SET constraint_exclusion TO on;
/*+SeqScan(p1)*/
QUERY PLAN
-----------------------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Seq Scan on p1
Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(5 rows)
+ Index Cond: (id < 10)
+(6 rows)
/*+IndexScan(p1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
duplication hint:
error hint:
- QUERY PLAN
---------------------------------------------------
- Nested Loop
+ QUERY PLAN
+-------------------------------------------------
+ Merge Join
+ Merge Cond: (p1.id = t1.id)
-> Index Scan using p1_pkey on p1
Index Cond: ((id >= 50) AND (id <= 51))
Filter: (ctid = '(1,1)'::tid)
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+ Index Cond: (id < 10)
+(7 rows)
/*+BitmapScan(p1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
QUERY PLAN
-------------------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Bitmap Heap Scan on p1
Recheck Cond: ((id >= 50) AND (id <= 51))
Filter: (ctid = '(1,1)'::tid)
-> Bitmap Index Scan on p1_pkey
Index Cond: ((id >= 50) AND (id <= 51))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(8 rows)
+ Index Cond: (id < 10)
+(9 rows)
/*+TidScan(p1)*/
EXPLAIN (COSTS false) SELECT * FROM ONLY p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10;
duplication hint:
error hint:
- QUERY PLAN
---------------------------------------------------
+ QUERY PLAN
+---------------------------------------------
Nested Loop
+ Join Filter: (p1.id = t1.id)
-> Tid Scan on p1
TID Cond: (ctid = '(1,1)'::tid)
Filter: ((id >= 50) AND (id <= 51))
-> Index Scan using t1_pkey on t1
- Index Cond: ((id = p1.id) AND (id < 10))
-(6 rows)
+ Index Cond: (id < 10)
+(7 rows)
-- quote test
/*+SeqScan("""t1 ) ")IndexScan("t 2 """)HashJoin("""t1 ) "T3"t 2 """)Leading("""t1 ) "T3"t 2 """)Set(application_name"a a a"" a A")*/
Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid))
(19 rows)
-/*+IndexScan(p2 p2_val)*/
+-- Inhibit parallel exection to avoid interfaring the hint
+set max_parallel_workers_per_gather to 0;
+/*+ IndexScan(p2 p2_val)*/
EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)';
LOG: available indexes for IndexScan(p2):
LOG: available indexes for IndexScan(p2_c1):
error hint:
\o
+set max_parallel_workers_per_gather to DEFAULT;
\! sql/maskout.sh results/pg_hint_plan.tmpout
QUERY PLAN
------------------------------------------------------------------------------------
(9 rows)
\! rm results/pg_hint_plan.tmpout
+-- hint error level
+set client_min_messages to 'DEBUG1';
+set pg_hint_plan.debug_level to 'verbose';
+/*+ SeqScan( */ SELECT 1;
+INFO: pg_hint_plan: hint syntax error at or near ""
+DETAIL: Closing parenthesis is necessary.
+ ?column?
+----------
+ 1
+(1 row)
+
+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
+LOG: pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+ id | val
+----+-----
+(0 rows)
+
+set pg_hint_plan.message_level to 'DEBUG1';
+set pg_hint_plan.parse_messages to 'NOTICE';
+/*+ SeqScan( */ SELECT 1;
+NOTICE: pg_hint_plan: hint syntax error at or near ""
+DETAIL: Closing parenthesis is necessary.
+ ?column?
+----------
+ 1
+(1 row)
+
+/*+ SeqScan(t1) */ SELECT * FROM t1 LIMIT 0;
+DEBUG: pg_hint_plan:
+used hint:
+SeqScan(t1)
+not used hint:
+duplication hint:
+error hint:
+
+ id | val
+----+-----
+(0 rows)
+