diff --git a/Makefile b/Makefile index 22ee13b40e63..4871b40f3ff8 100644 --- a/Makefile +++ b/Makefile @@ -56,6 +56,9 @@ TARSOURCES = Makefile *.c *.h COPYRIGHT* \ docs/* expected/*.out sql/*.sql sql/maskout*.sh \ data/data.csv SPECS/*.spec +LDFLAGS += -lyb_pggate_util +LDFLAGS += -L${BUILD_ROOT}/lib + rpms: rpm15 # pg_hint_plan.c includes core.c and make_join_rel.c diff --git a/expected/base_plan.out b/expected/base_plan.out index 9902f0d06499..1f23a1fd8c37 100644 --- a/expected/base_plan.out +++ b/expected/base_plan.out @@ -1,54 +1,35 @@ SET search_path TO public; -- query type 1 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) -- query type 2 EXPLAIN (COSTS false) SELECT * FROM t1, t4 WHERE t1.val < 10; - QUERY PLAN ------------------------------------------ + QUERY PLAN +----------------------------------- Nested Loop - -> Bitmap Heap Scan on t1 - Recheck Cond: (val < 10) - -> Bitmap Index Scan on t1_val - Index Cond: (val < 10) + -> Seq Scan on t1 + Remote Filter: (val < 10) -> Materialize -> Seq Scan on t4 -(7 rows) +(5 rows) +-- YB_COMMENT +-- CTID based scans and searches not supported in Yugabyte -- query type 3 -EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; - QUERY PLAN ---------------------------------------------- - Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - Filter: (ctid = '(1,1)'::tid) -(7 rows) - +-- EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; -- query type 4 -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(5 rows) - +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; -- query type 5 EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val; - QUERY PLAN + QUERY PLAN -------------------------------- Hash Join Hash Cond: (t1.val = t3.val) @@ -59,19 +40,19 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val; -- query type 6 EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(12 rows) - + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) diff --git a/expected/hints_anywhere.out b/expected/hints_anywhere.out index e126e759a068..c5dd36939a2b 100644 --- a/expected/hints_anywhere.out +++ b/expected/hints_anywhere.out @@ -1,16 +1,21 @@ LOAD 'pg_hint_plan'; +ERROR: LOAD not supported yet +LINE 1: LOAD 'pg_hint_plan'; + ^ +HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues 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) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) set pg_hint_plan.hints_anywhere = on; explain (costs false) @@ -22,7 +27,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -34,13 +39,14 @@ error hint: 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) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) set pg_hint_plan.hints_anywhere = on; /*+ MergeJoin(t1 t2) */ @@ -53,14 +59,17 @@ not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------- + 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) + -> Sort + Sort Key: t2.val + -> Seq Scan on t2 + -> Sort + Sort Key: t1.val + -> Seq Scan on t1 +(8 rows) /*+ HashJoin(t1 t2) */ explain (costs false) @@ -72,7 +81,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN -------------------------------- Hash Join Hash Cond: (t2.val = t1.val) @@ -80,4 +89,3 @@ error hint: -> Hash -> Seq Scan on t1 (5 rows) - diff --git a/expected/init.out b/expected/init.out index f7cb9dc4634a..ad61bb8aec6e 100644 --- a/expected/init.out +++ b/expected/init.out @@ -7,74 +7,51 @@ CREATE TABLE t3 (id int PRIMARY KEY, val int); CREATE TABLE t4 (id int PRIMARY KEY, val int); CREATE TABLE t5 (id int PRIMARY KEY, val int); CREATE TABLE p1 (id int PRIMARY KEY, val int); +-- TODOs INHERITANCE is unsupported +/* CREATE TABLE p1_c1 (LIKE p1 INCLUDING ALL, CHECK (id <= 100)) INHERITS(p1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 100 AND id <= 200)) INHERITS(p1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c3 (LIKE p1 INCLUDING ALL, CHECK (id > 200 AND id <= 300)) INHERITS(p1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c4 (LIKE p1 INCLUDING ALL, CHECK (id > 300)) INHERITS(p1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c1_c1 (LIKE p1 INCLUDING ALL, CHECK (id <= 50)) INHERITS(p1_c1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c1_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 50 AND id <= 100)) INHERITS(p1_c1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c3_c1 (LIKE p1 INCLUDING ALL, CHECK (id > 200 AND id <= 250)) INHERITS(p1_c3); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p1_c3_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 250 AND id <= 300)) INHERITS(p1_c3); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition +*/ CREATE TABLE p2 (id int PRIMARY KEY, val text); CREATE INDEX p2_id_val_idx ON p2 (id, val); CREATE UNIQUE INDEX p2_val_idx ON p2 (val); CREATE INDEX p2_ununi_id_val_idx ON p2 (val); CREATE INDEX p2_val_idx_1 ON p2 USING hash (val); +NOTICE: index method "hash" was replaced with "lsm" in YugabyteDB CREATE INDEX p2_val_id_idx ON p2 (val, id); CREATE INDEX p2_val_idx2 ON p2 (val COLLATE "C"); CREATE INDEX p2_val_idx3 ON p2 (val varchar_ops); CREATE INDEX p2_val_idx4 ON p2 (val DESC NULLS LAST); -CREATE INDEX p2_val_idx5 ON p2 (val NULLS FIRST); +CREATE INDEX p2_val_idx5 ON p2 (val ASC NULLS FIRST); CREATE INDEX p2_expr ON p2 ((val < '120')); CREATE INDEX p2_expr2 ON p2 ((id * 2 < 120)); CREATE INDEX p2_val_idx6 ON p2 (val) WHERE val >= '50' AND val < '51'; CREATE INDEX p2_val_idx7 ON p2 (val) WHERE id < 120; +-- TODOs INHERITANCE is unsupported +/* CREATE TABLE p2_c1 (LIKE p2 INCLUDING ALL, CHECK (id <= 100)) INHERITS(p2); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 100 AND id <= 200)) INHERITS(p2); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c3 (LIKE p2 INCLUDING ALL, CHECK (id > 200 AND id <= 300)) INHERITS(p2); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c4 (LIKE p2 INCLUDING ALL, CHECK (id > 300)) INHERITS(p2); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c1_c1 (LIKE p2 INCLUDING ALL, CHECK (id <= 50)) INHERITS(p2_c1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c1_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 50 AND id <= 100)) INHERITS(p2_c1); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c3_c1 (LIKE p2 INCLUDING ALL, CHECK (id > 200 AND id <= 250)) INHERITS(p2_c3); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition CREATE TABLE p2_c3_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 250 AND id <= 300)) INHERITS(p2_c3); -NOTICE: merging column "id" with inherited definition -NOTICE: merging column "val" with inherited definition +*/ CREATE TABLE s0.t1 (id int PRIMARY KEY, val int); INSERT INTO t1 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t; INSERT INTO t2 SELECT i, i % 10 FROM (SELECT generate_series(1, 1000) i) t; INSERT INTO t3 SELECT i, i FROM (SELECT generate_series(1, 100) i) t; INSERT INTO t4 SELECT i, i FROM (SELECT generate_series(1, 10) i) t; INSERT INTO t5 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t; +-- Queries that are dependent on tables that are created using including all and inherits. +/* INSERT INTO p1_c1_c1 SELECT i, i % 100 FROM (SELECT generate_series(1, 50) i) t; INSERT INTO p1_c1_c2 SELECT i, i % 100 FROM (SELECT generate_series(51, 100) i) t; INSERT INTO p1_c2 SELECT i, i % 100 FROM (SELECT generate_series(101, 200) i) t; @@ -87,21 +64,29 @@ INSERT INTO p2_c2 SELECT i, i % 100 FROM (SELECT generate_series(101, 200) i) t; INSERT INTO p2_c3_c1 SELECT i, i % 100 FROM (SELECT generate_series(201, 250) i) t; INSERT INTO p2_c3_c2 SELECT i, i % 100 FROM (SELECT generate_series(251, 300) i) t; INSERT INTO p2_c4 SELECT i, i % 100 FROM (SELECT generate_series(301, 400) i) t; +*/ CREATE INDEX t1_val ON t1 (val); CREATE INDEX t2_val ON t2 (val); CREATE INDEX t5_id1 ON t5 (id); CREATE INDEX t5_id2 ON t5 (id); CREATE INDEX t5_id3 ON t5 (id); CREATE INDEX t5_val ON t5 (val); +-- Queries that are dependent on tables that are created using including all and inherits. +/* DROP INDEX p2_c4_val_id_idx; +*/ CREATE INDEX p2_id2_val ON p2 (id, id, val); +/* CREATE INDEX p2_c1_id2_val ON p2_c1 (id, id, val); CREATE INDEX p2_c2_id2_val ON p2_c2 (id, id, val); +*/ CREATE INDEX p2_val2_id ON p2 (val, id, val); CREATE INDEX t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ON t5 (id); CREATE INDEX p1_val1 ON p1 (val); CREATE INDEX p1_val2 ON p1 (val); CREATE INDEX p1_val3 ON p1 (val); +-- Queries that are dependent on tables that are created using including all and inherits. +/* CREATE INDEX p1_c1_val1 ON p1_c1 (val); CREATE INDEX p1_c1_val2 ON p1_c1 (val); CREATE INDEX p1_c1_val3 ON p1_c1 (val); @@ -126,14 +111,17 @@ CREATE INDEX p1_c3_c2_val3 ON p1_c3_c2 (val); CREATE INDEX p1_c4_val1 ON p1_c4 (val); CREATE INDEX p1_c4_val2 ON p1_c4 (val); CREATE INDEX p1_c4_val3 ON p1_c4 (val); +*/ ANALYZE t1; ANALYZE t2; ANALYZE t3; ANALYZE t4; ANALYZE t5; ANALYZE p1; +/* ANALYZE p1_c1; ANALYZE p1_c2; +*/ ANALYZE p2; CREATE VIEW v1 AS SELECT id, val FROM t1; CREATE VIEW v2 AS SELECT t1.id t1_id, t1.val t1_val, t2.id t2_id, t2.val t2_val FROM t1, t2 WHERE t1.id = t2.id; @@ -145,21 +133,27 @@ CREATE VIEW v4 AS SELECT v_2.t1_id, t_3.id FROM v2 v_2, t3 t_3 WHERE v_2.t1_id = */ /* Fix auto-tunable parameters */ ALTER SYSTEM SET effective_cache_size TO 16384; +ERROR: ALTER SYSTEM not supported yet +LINE 6: ALTER SYSTEM SET effective_cache_size TO 16384; + ^ +HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues SELECT pg_reload_conf(); - pg_reload_conf + pg_reload_conf ---------------- t (1 row) SET effective_cache_size TO 16384; +-- YB: modify view to avoid yb_ settings. CREATE VIEW settings AS SELECT name, setting, category FROM pg_settings WHERE category LIKE 'Query Tuning%' + AND name NOT LIKE 'yb_%' OR name = 'client_min_messages' ORDER BY category, name; SELECT * FROM settings; - name | setting | category + name | setting | category --------------------------------+-----------+------------------------------------------------- client_min_messages | notice | Client Connection Defaults / Statement Behavior geqo | on | Query Tuning / Genetic Query Optimizer diff --git a/expected/oldextversions.out b/expected/oldextversions.out index 5a686951deda..d4a0ccd6e842 100644 --- a/expected/oldextversions.out +++ b/expected/oldextversions.out @@ -4,7 +4,7 @@ CREATE EXTENSION pg_hint_plan VERSION "1.3.0"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -13,7 +13,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.1"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -22,7 +22,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.2"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -31,7 +31,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.3"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -40,7 +40,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.4"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -49,7 +49,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.5"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -58,7 +58,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.6"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -67,7 +67,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.7"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -76,7 +76,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.8"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -85,7 +85,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.3.9"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -94,7 +94,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.4"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -103,7 +103,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.4.1"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -112,7 +112,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.4.2"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -121,7 +121,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.5"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints @@ -130,7 +130,7 @@ Objects in extension "pg_hint_plan" ALTER EXTENSION pg_hint_plan UPDATE TO "1.5.1"; \dx+ pg_hint_plan Objects in extension "pg_hint_plan" - Object description + Object description --------------------------------- sequence hint_plan.hints_id_seq table hint_plan.hints diff --git a/expected/pg_hint_plan.out b/expected/pg_hint_plan.out index 021c561ec7f5..469b33cd0d66 100644 --- a/expected/pg_hint_plan.out +++ b/expected/pg_hint_plan.out @@ -1,37 +1,47 @@ +-- This test is derived from the pg_hint_plan test in +-- . SET search_path TO public; SET client_min_messages TO log; \set SHOW_CONTEXT always +-- In general, for postgres since t1.id and t2.id is sorted, merge joins should be optimal. +-- However, since YB does not support merge join nested loop joins will be used. EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val; - QUERY PLAN -------------------------------------------- - Nested Loop + QUERY PLAN +--------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.val = t2.val) -> Seq Scan on t2 -> Memoize Cache Key: t2.val Cache Mode: logical -> Index Scan using t1_val on t1 - Index Cond: (val = t2.val) -(7 rows) + Index Cond: (val = ANY (ARRAY[t2.val, $1, $2, ..., $1023])) +(8 rows) LOAD 'pg_hint_plan'; +ERROR: LOAD not supported yet +LINE 1: LOAD 'pg_hint_plan'; + ^ +HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues SET pg_hint_plan.debug_print TO on; SELECT setting <> 'off' FROM pg_settings WHERE name = 'compute_query_id'; - ?column? + ?column? ---------- t (1 row) SHOW pg_hint_plan.enable_hint_table; - pg_hint_plan.enable_hint_table + pg_hint_plan.enable_hint_table -------------------------------- off (1 row) @@ -47,13 +57,13 @@ SET compute_query_id to off; SELECT 1; -- gets warining WARNING: hint table feature is deactivated because queryid is not available HINT: Set compute_query_id to "auto" or "on" to use hint table. - ?column? + ?column? ---------- 1 (1 row) SELECT 1; -- not - ?column? + ?column? ---------- 1 (1 row) @@ -61,7 +71,7 @@ SELECT 1; -- not SET compute_query_id to on; SELECT 1; -- reactivated LOG: hint table feature is reactivated - ?column? + ?column? ---------- 1 (1 row) @@ -70,7 +80,7 @@ SET compute_query_id to off; SELECT 1; -- gets warining WARNING: hint table feature is deactivated because queryid is not available HINT: Set compute_query_id to "auto" or "on" to use hint table. - ?column? + ?column? ---------- 1 (1 row) @@ -79,7 +89,7 @@ SET pg_hint_plan.enable_hint_table to off; SET compute_query_id to on; SET pg_hint_plan.enable_hint_table to on; SELECT 1; -- no warining - ?column? + ?column? ---------- 1 (1 row) @@ -87,82 +97,93 @@ SELECT 1; -- no warining RESET compute_query_id; RESET pg_hint_plan.enable_hint_table; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val; - QUERY PLAN -------------------------------------------- - Nested Loop + QUERY PLAN +--------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.val = t2.val) -> Seq Scan on t2 -> Memoize Cache Key: t2.val Cache Mode: logical -> Index Scan using t1_val on t1 - Index Cond: (val = t2.val) -(7 rows) + Index Cond: (val = ANY (ARRAY[t2.val, $1, $2, ..., $1023])) +(8 rows) +-- pg_hint_plan when enabled recognizes Test as an unknown keyword /*+ Test (t1 t2) */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; INFO: pg_hint_plan: hint syntax error at or near "Test (t1 t2) " DETAIL: Unrecognized hint keyword "Test". - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) SET pg_hint_plan.enable_hint TO off; /*+ Test (t1 t2) */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) SET pg_hint_plan.enable_hint TO on; +-- Planner Method Configuration parameters can be controlled as a part of pg_hint_plan comments. +-- pg_hint_plan comment formatting wrong /*Set(enable_indexscan off)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) +-- pg_hint_plan comment formatting wrong --+Set(enable_indexscan off) EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+Set(enable_indexscan off) /* nest comment */ */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; INFO: pg_hint_plan: hint syntax error at or near "/* nest comment */ */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id;" DETAIL: Nested block comments are not supported. - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+Set(enable_indexscan off)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -173,7 +194,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -182,6 +203,7 @@ error hint: -> Seq Scan on t2 (5 rows) +-- pg_hint_plan_comments can be used in between queries EXPLAIN (COSTS false) /*+Set(enable_indexscan off)*/ SELECT * FROM t1, t2 WHERE t1.id = t2.id; LOG: pg_hint_plan: @@ -191,7 +213,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -210,7 +232,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------- Merge Join Merge Cond: (t1.id = t2.id) @@ -231,7 +253,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -240,13 +262,13 @@ error hint: -> Seq Scan on t2 (5 rows) -/*+ - Set - ( - enable_indexscan - off - ) - */ +/*+ + Set + ( + enable_indexscan + off + ) + */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; LOG: pg_hint_plan: used hint: @@ -255,7 +277,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -264,7 +286,9 @@ error hint: -> Seq Scan on t2 (5 rows) -/*+ Set(enable_indexscan off)Set(enable_nestloop off)Set(enable_mergejoin off) +-- YB_COMMENT +-- Output of this query is different from postgres. Will change once YB optimizes planner +/*+ Set(enable_indexscan off)Set(enable_nestloop off)Set(enable_mergejoin off) Set(enable_seqscan off) */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -278,13 +302,13 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------- + QUERY PLAN +------------------------------ Hash Join Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 + -> Seq Scan on t1 -> Hash - -> Index Scan using t2_pkey on t2 + -> Seq Scan on t2 (5 rows) /*+Set(work_mem "1M")*/ @@ -298,13 +322,14 @@ duplication hint: error hint: Set(work_mem 1M) - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+Set(work_mem "1MB")*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -315,13 +340,14 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+Set(work_mem TO "1MB")*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -334,13 +360,14 @@ duplication hint: error hint: Set(work_mem TO 1MB) - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+SeqScan() */ SELECT 1; INFO: pg_hint_plan: hint syntax error at or near " " @@ -352,11 +379,13 @@ duplication hint: error hint: SeqScan() - ?column? + ?column? ---------- 1 (1 row) +-- SeqScan takes only 1 argument. Hence it appears in error hint and not in used hint in +-- the description. /*+SeqScan(t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; INFO: pg_hint_plan: hint syntax error at or near "" @@ -368,13 +397,14 @@ duplication hint: error hint: SeqScan(t1 t2) - QUERY PLAN --------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+SeqScan(t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -385,7 +415,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -404,15 +434,17 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------- - Hash Join - Hash Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) -> Seq Scan on t1 - -> Hash - -> Index Scan using t2_pkey on t2 + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $1, $2, ..., $1023])) (5 rows) +-- YB_COMMENT +-- Bitmapscan is not supported by YB /*+BitmapScan(t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; LOG: pg_hint_plan: @@ -422,15 +454,14 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------- - Nested Loop - -> Seq Scan on t1 - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(6 rows) + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+BitmapScan(t2)NoSeqScan(t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -442,15 +473,14 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------- - Nested Loop + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(6 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) /*+NoIndexScan(t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -461,7 +491,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -479,53 +509,21 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------- + QUERY PLAN +----------------------------------- Nested Loop -> Seq Scan on t1 - Filter: (val < 10) + Remote Filter: (val < 10) -> Materialize -> Seq Scan on t4 (5 rows) -/*+TidScan(t4)*/ -EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t4) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------ - Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 - -> Sort - Sort Key: t4.id - -> Tid Scan on t4 - TID Cond: (ctid = '(1,1)'::tid) -(7 rows) - -/*+NoTidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(5 rows) - +-- YB_COMMENT +-- Tid scan not supported by YB +-- /*+TidScan(t4)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; +-- /*+NoTidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; /*+ NestLoop() */ SELECT 1; INFO: pg_hint_plan: hint syntax error at or near " " DETAIL: NestLoop hint requires at least two relations. @@ -536,7 +534,7 @@ duplication hint: error hint: NestLoop() - ?column? + ?column? ---------- 1 (1 row) @@ -551,7 +549,7 @@ duplication hint: error hint: NestLoop(x) - ?column? + ?column? ---------- 1 (1 row) @@ -565,7 +563,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------ Hash Join Hash Cond: (t1.id = t2.id) @@ -583,7 +581,26 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN +-------------------------------------- + Nested Loop + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = t2.id) +(4 rows) + +-- YB_COMMENT +-- Because the plan defaults to a BNL in Yugabyte, add a NoYbBatchedNL test +/*+NoYbBatchedNL(t1 t2)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; +LOG: pg_hint_plan: +used hint: +NoYbBatchedNL(t1 t2) +not used hint: +duplication hint: +error hint: + + QUERY PLAN -------------------------------------- Nested Loop -> Seq Scan on t2 @@ -600,13 +617,13 @@ 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 + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) (5 rows) /*+MergeJoin(t1 t3)*/ @@ -618,15 +635,17 @@ not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------- + QUERY PLAN +--------------------------------- Merge Join - Merge Cond: (t1.val = t3.val) - -> Index Scan using t1_val on t1 + Merge Cond: (t3.val = t1.val) -> Sort Sort Key: t3.val -> Seq Scan on t3 -(6 rows) + -> Sort + Sort Key: t1.val + -> Seq Scan on t1 +(8 rows) /*+NestLoop(t1 t3)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val; @@ -637,7 +656,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------------- Nested Loop -> Seq Scan on t3 @@ -654,13 +673,14 @@ not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------- - Nested Loop + QUERY PLAN +--------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.val = t3.val) -> Seq Scan on t3 -> Index Scan using t1_val on t1 - Index Cond: (val = t3.val) -(4 rows) + Index Cond: (val = ANY (ARRAY[t3.val, $1, $2, ..., $1023])) +(5 rows) /*+MergeJoin(t4 t1 t2 t3)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -671,23 +691,46 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------- Merge Join Merge Cond: (t1.id = t3.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Materialize - -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 - -> Sort - Sort Key: t4.id + -> Sort + Sort Key: t1.id + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 -(13 rows) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Sort + Sort Key: t3.id + -> Seq Scan on t3 +(16 rows) +-- YB_COMMENT +-- If Merge joins were present, the inner two tables will utilize merge joins as id is a sorted +-- column. Since YB does not support merge join, the inner tables are joined using Nested Loop. +-- Output after Merge join support will look like this. +-- QUERY PLAN +-- -------------------------------------------------------- +-- Hash Join +-- Hash Cond: (t3.id = t1.id) +-- -> Seq Scan on t3 +-- -> Hash +-- -> Merge Join +-- Merge Cond: (t1.id = t4.id) +-- -> Merge Join +-- Merge Cond: (t1.id = t2.id) +-- -> Index Scan using t1_pkey on t1 +-- -> Index Scan using t2_pkey on t2 +-- -> Sort +-- Sort Key: t4.id +-- -> Seq Scan on t4 +-- (13 rows) /*+HashJoin(t3 t4 t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; LOG: pg_hint_plan: @@ -697,21 +740,21 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------------- Hash Join Hash Cond: (t3.id = t1.id) -> Seq Scan on t3 -> Hash - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) (13 rows) /*+NestLoop(t2 t3 t4 t1) IndexScan(t3)*/ @@ -724,19 +767,19 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------------- Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 Index Cond: (id = t1.id) (12 rows) @@ -749,42 +792,43 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- - Merge Join - Merge Cond: (t1.id = t3.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Materialize - -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 -(13 rows) - -/*+Leading( */ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; -INFO: pg_hint_plan: hint syntax error at or near "" -DETAIL: Closing parenthesis is necessary. - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) + -> Seq Scan on t4 -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) + +/*+Leading( */ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; +INFO: pg_hint_plan: hint syntax error at or near "" +DETAIL: Closing parenthesis is necessary. + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(12 rows) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) /*+Leading( )*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -797,21 +841,22 @@ duplication hint: error hint: Leading() - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(12 rows) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) /*+Leading( t3 )*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -824,21 +869,22 @@ duplication hint: error hint: Leading(t3) - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(12 rows) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) /*+Leading( t3 t4 )*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -849,21 +895,24 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- - Nested Loop + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) -> Nested Loop -> Merge Join Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 + -> Sort + Sort Key: t3.id + -> Seq Scan on t3 -> Sort Sort Key: t4.id -> Seq Scan on t4 - -> Index Scan using t2_pkey on t2 + -> Index Scan using t1_pkey on t1 Index Cond: (id = t3.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) -(12 rows) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2, $3, ..., $1024])) +(15 rows) /*+Leading(t3 t4 t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -874,21 +923,22 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t3.id = t1.id) - -> Merge Join - Merge Cond: (t3.id = t4.id) + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t1.id) + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t4.id) + -> Seq Scan on t4 -> Index Scan using t3_pkey on t3 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t3.id, $1025, $1026, ..., $2047])) -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(12 rows) + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) /*+Leading(t3 t4 t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -899,21 +949,22 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t3.id = t1.id) - -> Merge Join - Merge Cond: (t3.id = t4.id) + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t1.id) + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t4.id) + -> Seq Scan on t4 -> Index Scan using t3_pkey on t3 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t3.id, $1025, $1026, ..., $2047])) -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(12 rows) + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) /*+Leading(t3 t4 t1 t2 t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -926,21 +977,22 @@ duplication hint: error hint: Leading(t3 t4 t1 t2 t1) - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(12 rows) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) /*+Leading(t3 t4 t4)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; @@ -953,30 +1005,32 @@ duplication hint: error hint: Leading(t3 t4 t4) - QUERY PLAN --------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t4.id + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(12 rows) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $2049, $2050, ..., $3071])) +(13 rows) EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id; - QUERY PLAN ------------------------------------------------ - Nested Loop + QUERY PLAN +-------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = "*VALUES*".column1) -> Values Scan on "*VALUES*" -> Index Scan using t1_pkey on t1 - Index Cond: (id = "*VALUES*".column1) -(4 rows) + Index Cond: (id = ANY (ARRAY["*VALUES*".column1, $1, $2, ..., $1023])) +(5 rows) /*+HashJoin(t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id; @@ -987,13 +1041,14 @@ HashJoin(t1 t2) duplication hint: error hint: - QUERY PLAN ------------------------------------------------ - Nested Loop + QUERY PLAN +-------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = "*VALUES*".column1) -> Values Scan on "*VALUES*" -> Index Scan using t1_pkey on t1 - Index Cond: (id = "*VALUES*".column1) -(4 rows) + Index Cond: (id = ANY (ARRAY["*VALUES*".column1, $1, $2, ..., $1023])) +(5 rows) /*+HashJoin(t1 *VALUES*)*/ EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) WHERE t1.id = t2.id; @@ -1004,7 +1059,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------------------- Hash Join Hash Cond: (t1.id = "*VALUES*".column1) @@ -1024,35 +1079,35 @@ IndexScan(*VALUES*) duplication hint: error hint: - QUERY PLAN -------------------------------------------- - Hash Join - Hash Cond: (t1.id = "*VALUES*".column1) + QUERY PLAN +-------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = "*VALUES*".column1) + -> Values Scan on "*VALUES*" -> Index Scan using t1_pkey on t1 - -> Hash - -> Values Scan on "*VALUES*" + Index Cond: (id = ANY (ARRAY["*VALUES*".column1, $1, $2, ..., $1023])) (5 rows) -- single table scan hint test EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); - QUERY PLAN ------------------------------------------------------------------------- - Index Only Scan using t1_pkey on t1 - Index Cond: (id = $3) + QUERY PLAN +------------------------------------------ + Index Scan using t1_pkey on t1 + Index Cond: (id = $1) + InitPlan 1 (returns $0) + -> Finalize Aggregate + -> Seq Scan on t1 v_1 + Remote Filter: (id < 10) + Partial Aggregate: true InitPlan 2 (returns $1) - -> Result - InitPlan 1 (returns $0) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_1 - Index Cond: ((id IS NOT NULL) AND (id < 10)) - InitPlan 4 (returns $3) - -> Result - InitPlan 3 (returns $2) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_2 - Index Cond: ((id IS NOT NULL) AND (id < 10)) -(14 rows) + -> Finalize Aggregate + -> Seq Scan on t1 v_2 + Remote Filter: (id < 10) + Partial Aggregate: true +(12 rows) +-- YB_COMMENT +-- BitmapScan is not supported by YB /*+BitmapScan(v_1)*/ EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); LOG: pg_hint_plan: @@ -1062,5262 +1117,1732 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------- - Index Only Scan using t1_pkey on t1 - Index Cond: (id = $3) - InitPlan 1 (returns $1) - -> Aggregate - -> Bitmap Heap Scan on t1 v_1 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) - InitPlan 3 (returns $3) - -> Result - InitPlan 2 (returns $2) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_2 - Index Cond: ((id IS NOT NULL) AND (id < 10)) -(14 rows) - -/*+BitmapScan(v_2)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -LOG: pg_hint_plan: -used hint: -BitmapScan(v_2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------- - Index Only Scan using t1_pkey on t1 - Index Cond: (id = $3) + QUERY PLAN +------------------------------------------ + Index Scan using t1_pkey on t1 + Index Cond: (id = $1) + InitPlan 1 (returns $0) + -> Finalize Aggregate + -> Seq Scan on t1 v_1 + Remote Filter: (id < 10) + Partial Aggregate: true InitPlan 2 (returns $1) - -> Result - InitPlan 1 (returns $0) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_1 - Index Cond: ((id IS NOT NULL) AND (id < 10)) - InitPlan 3 (returns $3) - -> Aggregate - -> Bitmap Heap Scan on t1 v_2 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) -(14 rows) + -> Finalize Aggregate + -> Seq Scan on t1 v_2 + Remote Filter: (id < 10) + Partial Aggregate: true +(12 rows) -/*+BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_2)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_1)BitmapScan(v_2)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_1)BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_2)BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_1)BitmapScan(v_2)BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- +-- YB_COMMENT +-- CTID based scans and searches not supported in Yugabyte +-- full scan hint pattern test +EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +ERROR: System column "ctid" is not supported yet +-- /*+SeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+IndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+TidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoSeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoIndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoBitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoTidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+IndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+TidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoSeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoIndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoBitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoTidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- -- additional test +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; +-- /*+BitmapScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; +-- +-- -- outer join test +-- EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); +-- /*+MergeJoin(t1 t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); +-- -- Cannot work +-- /*+NestLoop(t1 t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); +-- +-- -- inheritance tables test +-- SET constraint_exclusion TO off; +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO on; +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- +-- SET constraint_exclusion TO off; +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- SET constraint_exclusion TO on; +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+NestLoop(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+MergeJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+HashJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+NestLoop(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+MergeJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+HashJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- +-- SET constraint_exclusion TO off; +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO on; +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+NestLoop(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; +-- /*+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; +-- /*+HashJoin(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; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+NestLoop(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; +-- /*+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; +-- /*+HashJoin(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; +-- +-- SET constraint_exclusion TO off; +-- 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; +-- 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; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(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; +-- /*+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; +-- /*+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; +-- /*+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; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(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; +-- /*+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; +-- /*+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; +-- /*+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; +-- IndexScan is safe for unordered indexes +CREATE TABLE ischk (a text, b tsvector) PARTITION BY LIST(a); +CREATE TABLE ischk_d1 PARTITION OF ischk FOR VALUES IN (0); +CREATE TABLE ischk_d2 PARTITION OF ischk FOR VALUES IN (1); +CREATE INDEX ischk_idx ON ischk USING gin (b); +LOG: substituting access method "gin" for "ybgin" +LOG: substituting access method "gin" for "ybgin" +LOG: substituting access method "gin" for "ybgin" +/*+ IndexScan(ischk ischk_idx) */ +EXPLAIN (COSTS false) SELECT * FROM ischk WHERE b = 'x'; +LOG: available indexes for IndexScan(ischk_d1): ischk_d1_b_idx +LOG: available indexes for IndexScan(ischk_d2): ischk_d2_b_idx LOG: pg_hint_plan: used hint: -BitmapScan(t1) +IndexScan(ischk ischk_idx) not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------- - Bitmap Heap Scan on t1 - Recheck Cond: (id = $3) - InitPlan 2 (returns $1) - -> Result - InitPlan 1 (returns $0) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_1 - Index Cond: ((id IS NOT NULL) AND (id < 10)) - InitPlan 4 (returns $3) - -> Result - InitPlan 3 (returns $2) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_2 - Index Cond: ((id IS NOT NULL) AND (id < 10)) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = $3) -(16 rows) + QUERY PLAN +------------------------------------------------------ + Gather + Workers Planned: 2 + -> Parallel Append + -> Seq Scan on ischk_d1 ischk_1 + Remote Filter: (b = '''x'''::tsvector) + -> Seq Scan on ischk_d2 ischk_2 + Remote Filter: (b = '''x'''::tsvector) +(7 rows) -/*+BitmapScan(v_1)BitmapScan(v_2)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +DROP TABLE ischk; +-- 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")*/ +EXPLAIN (COSTS false) SELECT * FROM t1 """t1 ) ", t2 "t 2 """, t3 "T3" WHERE """t1 ) ".id = "t 2 """.id AND """t1 ) ".id = "T3".id; LOG: pg_hint_plan: used hint: -BitmapScan(v_1) -BitmapScan(v_2) +SeqScan("""t1 ) ") +IndexScan("t 2 """) +HashJoin("""t1 ) " T3 "t 2 """) +Leading("""t1 ) " T3 "t 2 """) +Set(application_name "a a a"" a A") not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- - Index Only Scan using t1_pkey on t1 - Index Cond: (id = $3) - InitPlan 1 (returns $1) - -> Aggregate - -> Bitmap Heap Scan on t1 v_1 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) - InitPlan 2 (returns $3) - -> Aggregate - -> Bitmap Heap Scan on t1 v_2 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) -(14 rows) + QUERY PLAN +----------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: ("""t1 ) ".id = "t 2 """.id) + -> Hash Join + Hash Cond: ("""t1 ) ".id = "T3".id) + -> Seq Scan on t1 """t1 ) " + -> Hash + -> Seq Scan on t3 "T3" + -> Index Scan using t2_pkey on t2 "t 2 """ + Index Cond: (id = ANY (ARRAY["""t1 ) ".id, $1, $2, ..., $1023])) +(9 rows) -/*+BitmapScan(v_1)BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- duplicate hint test +-- YB_COMMENT +-- Removed TidScan because CTID based scans and searches not supported in Yugabyte +/*+SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; +INFO: pg_hint_plan: hint syntax error at or near "SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict scan method hint. +INFO: pg_hint_plan: hint syntax error at or near "IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict scan method hint. +INFO: pg_hint_plan: hint syntax error at or near "SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict scan method hint. +INFO: pg_hint_plan: hint syntax error at or near "IndexScan(t2)BitmapScan(t1)BitmapScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict scan method hint. +INFO: pg_hint_plan: hint syntax error at or near "HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict join method hint. +INFO: pg_hint_plan: hint syntax error at or near "NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict join method hint. +INFO: pg_hint_plan: hint syntax error at or near "Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict set hint. +INFO: pg_hint_plan: hint syntax error at or near "Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" +DETAIL: Conflict leading hint. LOG: pg_hint_plan: used hint: BitmapScan(t1) -BitmapScan(v_1) +BitmapScan(t2) +MergeJoin(t1 t2) +Leading(t2 t1) +Set(enable_mergejoin on) +Set(enable_seqscan on) not used hint: duplication hint: +SeqScan(t1) +IndexScan(t1) +SeqScan(t2) +IndexScan(t2) +HashJoin(t1 t2) +NestLoop(t1 t2) +Leading(t1 t2) +Set(enable_seqscan off) error hint: - QUERY PLAN ------------------------------------------------------------------------- - Bitmap Heap Scan on t1 - Recheck Cond: (id = $3) - InitPlan 1 (returns $1) - -> Aggregate - -> Bitmap Heap Scan on t1 v_1 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) - InitPlan 3 (returns $3) - -> Result - InitPlan 2 (returns $2) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_2 - Index Cond: ((id IS NOT NULL) AND (id < 10)) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = $3) -(16 rows) + QUERY PLAN +------------------------------- + Merge Join + Merge Cond: (t1.id = t2.id) + -> Sort + Sort Key: t1.id + -> Seq Scan on t1 + -> Sort + Sort Key: t2.id + -> Seq Scan on t2 +(8 rows) -/*+BitmapScan(v_2)BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -BitmapScan(v_2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------- - Bitmap Heap Scan on t1 - Recheck Cond: (id = $3) - InitPlan 2 (returns $1) - -> Result - InitPlan 1 (returns $0) - -> Limit - -> Index Only Scan Backward using t1_pkey on t1 v_1 - Index Cond: ((id IS NOT NULL) AND (id < 10)) - InitPlan 3 (returns $3) +-- sub query Leading hint test +SET from_collapse_limit TO 100; +SET geqo_threshold TO 100; +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) -> Aggregate - -> Bitmap Heap Scan on t1 v_2 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = $3) -(16 rows) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) +(51 rows) -/*+BitmapScan(v_1)BitmapScan(v_2)BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -BitmapScan(t1) -BitmapScan(v_1) -BitmapScan(v_2) +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------- - Bitmap Heap Scan on t1 - Recheck Cond: (id = $3) - InitPlan 1 (returns $1) + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) -> Aggregate - -> Bitmap Heap Scan on t1 v_1 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) - InitPlan 2 (returns $3) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) -> Aggregate - -> Bitmap Heap Scan on t1 v_2 - Recheck Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = $3) -(16 rows) - --- full scan hint pattern test -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; - QUERY PLAN ------------------------------------ - Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) -(3 rows) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) +(51 rows) -/*+SeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -SeqScan(t1) +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) not used hint: +Leading(a t1_1 t1_2 t1_4 t1_5) duplication hint: error hint: - QUERY PLAN -------------------------------------------------- - Seq Scan on t1 - Filter: ((id < 10) AND (ctid = '(1,1)'::tid)) -(2 rows) + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) +(51 rows) -/*+IndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -IndexScan(t1) +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) not used hint: +Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1) duplication hint: error hint: - QUERY PLAN ---------------------------------- - Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - Filter: (ctid = '(1,1)'::tid) -(3 rows) + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) +(51 rows) -/*+BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -BitmapScan(t1) +Leading(t3_5 t2_5 t1_5) +Leading(t3_2 t2_2 t1_2) +Leading(t3_4 t2_4 t1_4) +Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1) not used hint: +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) duplication hint: error hint: - QUERY PLAN ------------------------------------- - Bitmap Heap Scan on t1 - Recheck Cond: (id < 10) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id < 10) -(5 rows) - -/*+TidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -not used hint: -duplication hint: -error hint: + QUERY PLAN +--------------------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t2_2.id = t1_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t2_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t2_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t2_4.id = t1_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t2_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t2_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t2_5.id = t1_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t2_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t2_5.id, $5123, $5124, ..., $6145])) +(51 rows) - QUERY PLAN ------------------------------------ - Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) -(3 rows) +SET from_collapse_limit TO 1; +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) +(51 rows) -/*+NoSeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -NoSeqScan(t1) +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------ - Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) -(3 rows) + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- + Nested Loop + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) +(51 rows) -/*+NoIndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -NoIndexScan(t1) +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) not used hint: +Leading(a t1_1 t1_2 t1_4 t1_5) duplication hint: error hint: - QUERY PLAN ------------------------------------ - Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) -(3 rows) - -/*+NoBitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------ - Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) -(3 rows) - -/*+NoTidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - Filter: (ctid = '(1,1)'::tid) -(3 rows) - -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+SeqScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+SeqScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - Join Filter: (t1.id = t2.id) - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Index Scan using t2_pkey on t2 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Index Scan using t1_pkey on t1 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+IndexScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+IndexScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+BitmapScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Index Scan using t2_pkey on t2 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Index Scan using t2_pkey on t2 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+BitmapScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t1 - Recheck Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: (id = t2.id) -(8 rows) - -/*+TidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+TidScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+TidScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+NoSeqScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoSeqScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoSeqScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+NoIndexScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoIndexScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoIndexScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+NoBitmapScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoBitmapScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoBitmapScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -SeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -IndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Index Scan using t2_pkey on t2 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------- - Nested Loop - -> Seq Scan on t1 - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Heap Scan on t2 - Recheck Cond: (id = t1.id) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id = t1.id) -(8 rows) - -/*+NoTidScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -TidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -NoSeqScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -NoIndexScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -NoBitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Nested Loop - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - -/*+NoTidScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -NoTidScan(t1) -NoTidScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Nested Loop - -> Seq Scan on t2 - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t2.id) - Filter: (ctid = '(1,1)'::tid) -(6 rows) - --- additional test -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; - QUERY PLAN ------------------------------------------ - Nested Loop - Join Filter: (t1.id = t2.id) - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) - Filter: (id < 10) -(8 rows) - -/*+BitmapScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; -LOG: pg_hint_plan: -used hint: -BitmapScan(t1) -BitmapScan(t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------------------- - Nested Loop - -> Bitmap Heap Scan on t2 - Recheck Cond: (id < 10) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t2_pkey - Index Cond: (id < 10) - -> Bitmap Heap Scan on t1 - Recheck Cond: ((id = t2.id) AND (id < 10)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on t1_pkey - Index Cond: ((id = t2.id) AND (id < 10)) -(11 rows) - --- outer join test -EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); - QUERY PLAN ------------------------------- - Hash Full Join - Hash Cond: (t1.id = t2.id) - -> Seq Scan on t1 - -> Hash - -> Seq Scan on t2 -(5 rows) - -/*+MergeJoin(t1 t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -MergeJoin(t1 t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN --------------------------------------- - Merge Full Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 -(4 rows) - --- Cannot work -/*+NestLoop(t1 t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -NestLoop(t1 t2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------- - Hash Full Join - Hash Cond: (t1.id = t2.id) - -> Seq Scan on t1 - -> Hash - -> Seq Scan on t2 -(5 rows) - --- inheritance tables test -SET constraint_exclusion TO off; -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(19 rows) - -SET constraint_exclusion TO on; -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(9 rows) - -SET constraint_exclusion TO off; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(19 rows) - -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p1_pkey on p1 p1_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_pkey on p1_c1 p1_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c2_pkey on p1_c2 p1_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c3_pkey on p1_c3 p1_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c4_pkey on p1_c4 p1_5 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_6 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_7 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c3_c1_pkey on p1_c3_c1 p1_8 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c3_c2_pkey on p1_c3_c2 p1_9 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(28 rows) - -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------- - Append - -> Bitmap Heap Scan on p1 p1_1 - 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)) - -> Bitmap Heap Scan on p1_c1 p1_2 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c2 p1_3 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c3 p1_4 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c3_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c4 p1_5 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c4_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c1 p1_6 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c2 p1_7 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c3_c1 p1_8 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c3_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c3_c2 p1_9 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c3_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) -(46 rows) - -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------------- - Append - -> Tid Scan on p1 p1_1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1 p1_2 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c2 p1_3 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c3 p1_4 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c4 p1_5 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c1 p1_6 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c2 p1_7 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c3_c1 p1_8 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c3_c2 p1_9 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) -(28 rows) - -SET constraint_exclusion TO on; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(9 rows) - -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p1_pkey on p1 p1_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_pkey on p1_c1 p1_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) - -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------- - Append - -> Bitmap Heap Scan on p1 p1_1 - 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)) - -> Bitmap Heap Scan on p1_c1 p1_2 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c1 p1_3 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c2 p1_4 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) -(21 rows) - -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------------- - Append - -> Tid Scan on p1 p1_1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1 p1_2 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c1 p1_3 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c2 p1_4 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) -(13 rows) - -SET constraint_exclusion TO off; -EXPLAIN (COSTS false) SELECT * FROM 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 ------------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(25 rows) - -SET constraint_exclusion TO on; -EXPLAIN (COSTS false) SELECT * FROM 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 ------------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(15 rows) - -SET constraint_exclusion TO off; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(25 rows) - -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------- - Merge Join - Merge Cond: (p1.id = t1.id) - -> Merge Append - Sort Key: p1.id - -> Index Scan using p1_pkey on p1 p1_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_pkey on p1_c1 p1_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c2_pkey on p1_c2 p1_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c3_pkey on p1_c3 p1_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c4_pkey on p1_c4 p1_5 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_6 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_7 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c3_c1_pkey on p1_c3_c1 p1_8 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c3_c2_pkey on p1_c3_c2 p1_9 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(33 rows) - -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------------- - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Bitmap Heap Scan on p1 p1_1 - 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)) - -> Bitmap Heap Scan on p1_c1 p1_2 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c2 p1_3 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c3 p1_4 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c3_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c4 p1_5 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c4_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c1 p1_6 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c2 p1_7 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c3_c1 p1_8 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c3_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c3_c2 p1_9 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c3_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(52 rows) - -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------------------------- - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Tid Scan on p1 p1_1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1 p1_2 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c2 p1_3 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c3 p1_4 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c4 p1_5 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c1 p1_6 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c2 p1_7 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c3_c1 p1_8 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c3_c2 p1_9 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(34 rows) - -/*+NestLoop(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -NestLoop(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------ - Nested Loop - Join Filter: (p1.id = t1.id) - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Materialize - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(24 rows) - -/*+MergeJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -MergeJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(25 rows) - -/*+HashJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -HashJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------ - Hash Join - Hash Cond: (p1.id = t1.id) - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c2 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c4 p1_5 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(24 rows) - -SET constraint_exclusion TO on; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(15 rows) - -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------- - Merge Join - Merge Cond: (p1.id = t1.id) - -> Merge Append - Sort Key: p1.id - -> Index Scan using p1_pkey on p1 p1_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_pkey on p1_c1 p1_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c1_pkey on p1_c1_c1 p1_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p1_c1_c2_pkey on p1_c1_c2 p1_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(18 rows) - -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------------- - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Bitmap Heap Scan on p1 p1_1 - 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)) - -> Bitmap Heap Scan on p1_c1 p1_2 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c1 p1_3 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c1_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Bitmap Heap Scan on p1_c1_c2 p1_4 - Recheck Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Bitmap Index Scan on p1_c1_c2_pkey - Index Cond: ((id >= 50) AND (id <= 51)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(27 rows) - -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------------------------- - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Tid Scan on p1 p1_1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1 p1_2 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c1 p1_3 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Tid Scan on p1_c1_c2 p1_4 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(19 rows) - -/*+NestLoop(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -NestLoop(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------ - Nested Loop - Join Filter: (p1.id = t1.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Materialize - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(14 rows) - -/*+MergeJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -MergeJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.id - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(15 rows) - -/*+HashJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -HashJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------ - Hash Join - Hash Cond: (t1.id = p1.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Append - -> Seq Scan on p1 p1_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1 p1_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c1 p1_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p1_c1_c2 p1_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(14 rows) - -SET constraint_exclusion TO off; -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------------------------------ - Seq Scan on p1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(2 rows) - -SET constraint_exclusion TO on; -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------------------------------ - Seq Scan on p1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(2 rows) - -SET constraint_exclusion TO off; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------ - Seq Scan on p1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(2 rows) - -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------- - Index Scan using p1_pkey on p1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(3 rows) - -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------- - 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)) -(5 rows) - -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Tid Scan on p1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) -(3 rows) - -/*+NestLoop(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; -LOG: pg_hint_plan: -used hint: -NestLoop(p1 t1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -MergeJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.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 < 10) -(8 rows) - -/*+HashJoin(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; -LOG: pg_hint_plan: -used hint: -HashJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------ - Hash Join - Hash Cond: (t1.id = p1.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on p1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(7 rows) - -SET constraint_exclusion TO on; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------ - Seq Scan on p1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(2 rows) - -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------- - Index Scan using p1_pkey on p1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(3 rows) - -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------- - 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)) -(5 rows) - -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------- - Tid Scan on p1 - TID Cond: (ctid = '(1,1)'::tid) - Filter: ((id >= 50) AND (id <= 51)) -(3 rows) - -/*+NestLoop(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; -LOG: pg_hint_plan: -used hint: -NestLoop(p1 t1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -MergeJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------ - Merge Join - Merge Cond: (p1.id = t1.id) - -> Sort - Sort Key: p1.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 < 10) -(8 rows) - -/*+HashJoin(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; -LOG: pg_hint_plan: -used hint: -HashJoin(p1 t1) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------ - Hash Join - Hash Cond: (t1.id = p1.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on p1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(7 rows) - -SET constraint_exclusion TO off; -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 < 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 < 10) -(6 rows) - -SET constraint_exclusion TO off; -/*+SeqScan(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; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 10) -(7 rows) - -SET constraint_exclusion TO on; -/*+SeqScan(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; -LOG: pg_hint_plan: -used hint: -SeqScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -IndexScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -BitmapScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 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; -LOG: pg_hint_plan: -used hint: -TidScan(p1) -not used hint: -duplication hint: -error hint: - - 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 < 10) -(7 rows) - --- IndexScan is safe for unordered indexes -CREATE TABLE ischk (a text, b tsvector) PARTITION BY LIST(a); -CREATE TABLE ischk_d1 PARTITION OF ischk FOR VALUES IN (0); -CREATE TABLE ischk_d2 PARTITION OF ischk FOR VALUES IN (1); -CREATE INDEX ischk_idx ON ischk USING gin (b); -/*+ IndexScan(ischk ischk_idx) */ -EXPLAIN (COSTS false) SELECT * FROM ischk WHERE b = 'x'; -LOG: available indexes for IndexScan(ischk_d1): ischk_d1_b_idx -LOG: available indexes for IndexScan(ischk_d2): ischk_d2_b_idx -LOG: pg_hint_plan: -used hint: -IndexScan(ischk ischk_idx) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------ - Append - -> Seq Scan on ischk_d1 ischk_1 - Filter: (b = '''x'''::tsvector) - -> Seq Scan on ischk_d2 ischk_2 - Filter: (b = '''x'''::tsvector) -(5 rows) - -DROP TABLE ischk; --- 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")*/ -EXPLAIN (COSTS false) SELECT * FROM t1 """t1 ) ", t2 "t 2 """, t3 "T3" WHERE """t1 ) ".id = "t 2 """.id AND """t1 ) ".id = "T3".id; -LOG: pg_hint_plan: -used hint: -SeqScan("""t1 ) ") -IndexScan("t 2 """) -HashJoin("""t1 ) " T3 "t 2 """) -Leading("""t1 ) " T3 "t 2 """) -Set(application_name "a a a"" a A") -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------------------------- - Hash Join - Hash Cond: ("t 2 """.id = """t1 ) ".id) - -> Index Scan using t2_pkey on t2 "t 2 """ - -> Hash - -> Hash Join - Hash Cond: ("""t1 ) ".id = "T3".id) - -> Seq Scan on t1 """t1 ) " - -> Hash - -> Seq Scan on t3 "T3" -(9 rows) - --- duplicate hint test -/*+SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -INFO: pg_hint_plan: hint syntax error at or near "SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict scan method hint. -INFO: pg_hint_plan: hint syntax error at or near "IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict scan method hint. -INFO: pg_hint_plan: hint syntax error at or near "BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict scan method hint. -INFO: pg_hint_plan: hint syntax error at or near "SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict scan method hint. -INFO: pg_hint_plan: hint syntax error at or near "IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict scan method hint. -INFO: pg_hint_plan: hint syntax error at or near "BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict scan method hint. -INFO: pg_hint_plan: hint syntax error at or near "HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict join method hint. -INFO: pg_hint_plan: hint syntax error at or near "NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict join method hint. -INFO: pg_hint_plan: hint syntax error at or near "Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict set hint. -INFO: pg_hint_plan: hint syntax error at or near "Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)" -DETAIL: Conflict leading hint. -LOG: pg_hint_plan: -used hint: -TidScan(t1) -TidScan(t2) -MergeJoin(t1 t2) -Leading(t2 t1) -Set(enable_mergejoin on) -Set(enable_seqscan on) -not used hint: -duplication hint: -SeqScan(t1) -IndexScan(t1) -BitmapScan(t1) -SeqScan(t2) -IndexScan(t2) -BitmapScan(t2) -HashJoin(t1 t2) -NestLoop(t1 t2) -Leading(t1 t2) -Set(enable_seqscan off) -error hint: - - QUERY PLAN ------------------------------------------------ - Merge Join - Merge Cond: (t1.id = t2.id) - -> Sort - Sort Key: t1.id - -> Tid Scan on t1 - TID Cond: (ctid = '(1,1)'::tid) - -> Sort - Sort Key: t2.id - -> Tid Scan on t2 - TID Cond: (ctid = '(1,1)'::tid) -(10 rows) - --- sub query Leading hint test -SET from_collapse_limit TO 100; -SET geqo_threshold TO 100; -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); - QUERY PLAN ------------------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $0) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Merge Join - Merge Cond: (t1_2.id = t2_2.id) - -> Index Only Scan using t1_pkey on t1 t1_2 - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Merge Join - Merge Cond: (t1_4.id = t2_4.id) - -> Index Only Scan using t1_pkey on t1 t1_4 - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $1) - -> Seq Scan on t3 t3_1 - Filter: (id = $1) - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $1) - -> Seq Scan on t3 t3_3 - Filter: (id = $1) - -> Aggregate - Filter: (max(t1_5.id) = $1) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Merge Join - Merge Cond: (t1_5.id = t2_5.id) - -> Index Only Scan using t1_pkey on t1 t1_5 - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $3) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - Index Cond: (id = t2_4.id) - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_1 - Filter: (id = $3) - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_3 - Filter: (id = $3) - -> Aggregate - Filter: (max(t1_5.id) = $3) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - Index Cond: (id = t2_5.id) - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -not used hint: -Leading(a t1_1 t1_2 t1_4 t1_5) -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $3) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - Index Cond: (id = t2_4.id) - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_1 - Filter: (id = $3) - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_3 - Filter: (id = $3) - -> Aggregate - Filter: (max(t1_5.id) = $3) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - Index Cond: (id = t2_5.id) - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -not used hint: -Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1) -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $3) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - Index Cond: (id = t2_4.id) - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_1 - Filter: (id = $3) - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_3 - Filter: (id = $3) - -> Aggregate - Filter: (max(t1_5.id) = $3) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - Index Cond: (id = t2_5.id) - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -Leading(t3_5 t2_5 t1_5) -Leading(t3_2 t2_2 t1_2) -Leading(t3_4 t2_4 t1_4) -Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1) -not used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $0) - -> Aggregate - -> Merge Join - Merge Cond: (t2_2.id = t1_2.id) - -> Merge Join - Merge Cond: (t2_2.id = t3_2.id) - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - InitPlan 2 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t2_4.id = t1_4.id) - -> Merge Join - Merge Cond: (t2_4.id = t3_4.id) - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Seq Scan on t3 t3_3 - Filter: (id = $1) - -> Aggregate - Filter: (max(t1_5.id) = $1) - -> Merge Join - Merge Cond: (t2_5.id = t1_5.id) - -> Merge Join - Merge Cond: (t2_5.id = t3_5.id) - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $1) - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $1) - -> Seq Scan on t3 t3_1 - Filter: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $1) - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $1) -(51 rows) - -SET from_collapse_limit TO 1; -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); - QUERY PLAN --------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $0) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Merge Join - Merge Cond: (t1_2.id = t2_2.id) - -> Index Only Scan using t1_pkey on t1 t1_2 - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Merge Join - Merge Cond: (t1_4.id = t2_4.id) - -> Index Only Scan using t1_pkey on t1 t1_4 - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $1) - -> Seq Scan on t3 t3_1 - Filter: (id = $1) - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $1) - -> Seq Scan on t3 t3_3 - Filter: (id = $1) - -> Aggregate - Filter: (max(t1_5.id) = $1) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Merge Join - Merge Cond: (t1_5.id = t2_5.id) - -> Index Only Scan using t1_pkey on t1 t1_5 - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -not used hint: -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $3) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - Index Cond: (id = t2_4.id) - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_1 - Filter: (id = $3) - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_3 - Filter: (id = $3) - -> Aggregate - Filter: (max(t1_5.id) = $3) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - Index Cond: (id = t2_5.id) - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -not used hint: -Leading(a t1_1 t1_2 t1_4 t1_5) -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $3) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - Index Cond: (id = t2_4.id) - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_1 - Filter: (id = $3) - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_3 - Filter: (id = $3) - -> Aggregate - Filter: (max(t1_5.id) = $3) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - Index Cond: (id = t2_5.id) - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -MergeJoin(t1_3 t3_3) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -not used hint: -Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1) -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t1_2.id = t3_2.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - InitPlan 2 (returns $3) - -> Aggregate - -> Merge Join - Merge Cond: (t1_4.id = t3_4.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - Index Cond: (id = t2_4.id) - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_1 - Filter: (id = $3) - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $3) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $3) - -> Seq Scan on t3 t3_3 - Filter: (id = $3) - -> Aggregate - Filter: (max(t1_5.id) = $3) - -> Merge Join - Merge Cond: (t1_5.id = t3_5.id) - -> Nested Loop - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - Index Cond: (id = t2_5.id) - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 -(51 rows) - -/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/ -EXPLAIN (COSTS false) -WITH c1_1(id) AS ( -SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id -) -SELECT t1_1.id, ( -SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id -) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( -SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id -) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id -); -LOG: pg_hint_plan: -used hint: -MergeJoin(t1_3 t3_3) -Leading(t3_5 t2_5 t1_5) -Leading(t3_2 t2_2 t1_2) -Leading(t3_4 t2_4 t1_4) -Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1) -not used hint: -HashJoin(t1_1 t3_1) -NestLoop(t1_2 t2_2) -NestLoop(t1_4 t2_4) -NestLoop(t1_5 t2_5) -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------------------------------- - Nested Loop - InitPlan 1 (returns $0) - -> Aggregate - -> Merge Join - Merge Cond: (t2_2.id = t1_2.id) - -> Merge Join - Merge Cond: (t2_2.id = t3_2.id) - -> Index Only Scan using t2_pkey on t2 t2_2 - -> Sort - Sort Key: t3_2.id - -> Seq Scan on t3 t3_2 - -> Index Only Scan using t1_pkey on t1 t1_2 - InitPlan 2 (returns $1) - -> Aggregate - -> Merge Join - Merge Cond: (t2_4.id = t1_4.id) - -> Merge Join - Merge Cond: (t2_4.id = t3_4.id) - -> Index Only Scan using t2_pkey on t2 t2_4 - -> Sort - Sort Key: t3_4.id - -> Seq Scan on t3 t3_4 - -> Index Only Scan using t1_pkey on t1 t1_4 - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Nested Loop - -> Index Only Scan using t1_pkey on t1 t1_3 - Index Cond: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_3 - Index Cond: (id = $1) - -> Seq Scan on t3 t3_3 - Filter: (id = $1) - -> Aggregate - Filter: (max(t1_5.id) = $1) - -> Merge Join - Merge Cond: (t2_5.id = t1_5.id) - -> Merge Join - Merge Cond: (t2_5.id = t3_5.id) - -> Index Only Scan using t2_pkey on t2 t2_5 - -> Sort - Sort Key: t3_5.id - -> Seq Scan on t3 t3_5 - -> Index Only Scan using t1_pkey on t1 t1_5 - -> Seq Scan on t3 t3_1 - Filter: (id = $1) - -> Index Only Scan using t2_pkey on t2 t2_1 - Index Cond: (id = $1) - -> Index Only Scan using t1_pkey on t1 t1_1 - Index Cond: (id = $1) -(51 rows) - --- ambiguous error -EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id; - QUERY PLAN --------------------------------------------- - Nested Loop - -> Nested Loop - -> Seq Scan on t1 t1_1 - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t1_1.id) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(7 rows) - -/*+MergeJoin(t1 t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id; -INFO: pg_hint_plan: hint syntax error at or near "MergeJoin(t1 t2)" -DETAIL: Relation name "t1" is ambiguous. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -MergeJoin(t1 t2) - - QUERY PLAN --------------------------------------------- - Nested Loop - -> Nested Loop - -> Seq Scan on t1 t1_1 - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t1_1.id) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(7 rows) - -/*+Leading(t1 t2 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id; -INFO: pg_hint_plan: hint syntax error at or near "Leading(t1 t2 t1)" -DETAIL: Relation name "t1" is ambiguous. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Leading(t1 t2 t1) - - QUERY PLAN --------------------------------------------- - Nested Loop - -> Nested Loop - -> Seq Scan on t1 t1_1 - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t1_1.id) - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(7 rows) - --- identifier length test -EXPLAIN (COSTS false) SELECT * FROM t1 "123456789012345678901234567890123456789012345678901234567890123" JOIN t2 ON ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) JOIN t3 ON (t2.id = t3.id); - QUERY PLAN --------------------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id) - -> Merge Join - Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) - -> Index Scan using t1_pkey on t1 "123456789012345678901234567890123456789012345678901234567890123" - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t3.id - -> Seq Scan on t3 -(9 rows) - -/*+ -Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3) -SeqScan(123456789012345678901234567890123456789012345678901234567890123) -MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2) -Set(123456789012345678901234567890123456789012345678901234567890123 1) -*/ -EXPLAIN (COSTS false) SELECT * FROM t1 "123456789012345678901234567890123456789012345678901234567890123" JOIN t2 ON ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) JOIN t3 ON (t2.id = t3.id); -INFO: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" -LOG: pg_hint_plan: -used hint: -SeqScan(123456789012345678901234567890123456789012345678901234567890123) -MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2) -Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3) -not used hint: -duplication hint: -error hint: -Set(123456789012345678901234567890123456789012345678901234567890123 1) - - QUERY PLAN ----------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id) - -> Merge Join - Merge Cond: (t2.id = "123456789012345678901234567890123456789012345678901234567890123".id) - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: "123456789012345678901234567890123456789012345678901234567890123".id - -> Seq Scan on t1 "123456789012345678901234567890123456789012345678901234567890123" - -> Sort - Sort Key: t3.id - -> Seq Scan on t3 -(11 rows) - -/*+ -Leading(1234567890123456789012345678901234567890123456789012345678901234 t2 t3) -SeqScan(1234567890123456789012345678901234567890123456789012345678901234) -MergeJoin(1234567890123456789012345678901234567890123456789012345678901234 t2) -Set(1234567890123456789012345678901234567890123456789012345678901234 1) -Set(cursor_tuple_fraction 0.1234567890123456789012345678901234567890123456789012345678901234) -*/ -EXPLAIN (COSTS false) SELECT * FROM t1 "1234567890123456789012345678901234567890123456789012345678901234" JOIN t2 ON ("1234567890123456789012345678901234567890123456789012345678901234".id = t2.id) JOIN t3 ON (t2.id = t3.id); -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -INFO: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" -LOG: pg_hint_plan: -used hint: -SeqScan(123456789012345678901234567890123456789012345678901234567890123) -MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2) -Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3) -Set(cursor_tuple_fraction 0.1234567890123456789012345678901234567890123456789012345678901234) -not used hint: -duplication hint: -error hint: -Set(123456789012345678901234567890123456789012345678901234567890123 1) - - QUERY PLAN ----------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id) - -> Merge Join - Merge Cond: (t2.id = "123456789012345678901234567890123456789012345678901234567890123".id) - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: "123456789012345678901234567890123456789012345678901234567890123".id - -> Seq Scan on t1 "123456789012345678901234567890123456789012345678901234567890123" - -> Sort - Sort Key: t3.id - -> Seq Scan on t3 -(11 rows) - -SET "123456789012345678901234567890123456789012345678901234567890123" TO 1; -ERROR: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" -SET "1234567890123456789012345678901234567890123456789012345678901234" TO 1; -NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" -ERROR: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" -SET cursor_tuple_fraction TO 1234567890123456789012345678901234567890123456789012345678901234; -ERROR: 1.23457e+63 is outside the valid range for parameter "cursor_tuple_fraction" (0 .. 1) --- multi error -/*+ Set(enable_seqscan 100)Set(seq_page_cost on)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; -INFO: parameter "enable_seqscan" requires a Boolean value -INFO: invalid value for parameter "seq_page_cost": "on" -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Set(enable_seqscan 100) -Set(seq_page_cost on) - - 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) - --- debug log of candidate index to use IndexScan -EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; - QUERY PLAN ----------------------------------------------------------------------------------------- - Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - Index Cond: (id = 1) -(2 rows) - -/*+IndexScan(t5 t5_id2)*/ -EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; -LOG: available indexes for IndexScan(t5): t5_id2 -LOG: pg_hint_plan: -used hint: -IndexScan(t5 t5_id2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------- - Index Scan using t5_id2 on t5 - Index Cond: (id = 1) -(2 rows) - -/*+IndexScan(t5 no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; -LOG: available indexes for IndexScan(t5): -LOG: pg_hint_plan: -used hint: -not used hint: -IndexScan(t5 no_exist) -duplication hint: -error hint: - - QUERY PLAN ----------------------------------------------------------------------------------------- - Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - Index Cond: (id = 1) -(2 rows) - -/*+IndexScan(t5 t5_id1 t5_id2)*/ -EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; -LOG: available indexes for IndexScan(t5): t5_id2 t5_id1 -LOG: pg_hint_plan: -used hint: -IndexScan(t5 t5_id1 t5_id2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------- - Index Scan using t5_id2 on t5 - Index Cond: (id = 1) -(2 rows) - -/*+IndexScan(t5 no_exist t5_id2)*/ -EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; -LOG: available indexes for IndexScan(t5): t5_id2 -LOG: pg_hint_plan: -used hint: -IndexScan(t5 no_exist t5_id2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------- - Index Scan using t5_id2 on t5 - Index Cond: (id = 1) -(2 rows) - -/*+IndexScan(t5 no_exist5 no_exist2)*/ -EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; -LOG: available indexes for IndexScan(t5): -LOG: pg_hint_plan: -used hint: -not used hint: -IndexScan(t5 no_exist5 no_exist2) -duplication hint: -error hint: - - QUERY PLAN ----------------------------------------------------------------------------------------- - Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - Index Cond: (id = 1) -(2 rows) - --- outer inner -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; - QUERY PLAN --------------------------------------------------------- - Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 - -> Hash - -> Hash Join - Hash Cond: (t2.id = t1.id) - -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(10 rows) - -/*+Leading((t1))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; -INFO: pg_hint_plan: hint syntax error at or near "Leading((t1))" -DETAIL: Leading hint requires two sets of relations when parentheses nests. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Leading((t1)) - - QUERY PLAN --------------------------------------------------------- - Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 - -> Hash - -> Hash Join - Hash Cond: (t2.id = t1.id) - -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(10 rows) - -/*+Leading((t1 t2))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -Leading((t1 t2)) -not used hint: -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- Nested Loop - Join Filter: (t2.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 -(9 rows) - -/*+Leading((t1 t2 t3))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; -INFO: pg_hint_plan: hint syntax error at or near "Leading((t1 t2 t3))" -DETAIL: Leading hint requires two sets of relations when parentheses nests. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Leading((t1 t2 t3)) - - QUERY PLAN --------------------------------------------------------- - Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 - -> Hash - -> Hash Join - Hash Cond: (t2.id = t1.id) - -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(10 rows) - -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.id < 10; - QUERY PLAN --------------------------------------------- - Hash Join - Hash Cond: (t2.id = t1.id) - -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(6 rows) - -/*+Leading((t1 t2))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -Leading((t1 t2)) -not used hint: -duplication hint: -error hint: - - QUERY PLAN --------------------------------------- - Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 -(6 rows) - -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; - QUERY PLAN --------------------------------------------------------- - Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 - -> Hash - -> Hash Join - Hash Cond: (t2.id = t1.id) - -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(10 rows) + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) +(51 rows) -/*+Leading(((t1 t2) t3))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -Leading(((t1 t2) t3)) +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +MergeJoin(t1_3 t3_3) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) not used hint: +Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1) duplication hint: error hint: - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t2.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 -(9 rows) - -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; - QUERY PLAN --------------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- Nested Loop - -> Merge Join - Merge Cond: (t3.id = t4.id) + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t1_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t2_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t1_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) -> Nested Loop - Join Filter: (t1.val = t3.val) - -> Index Scan using t3_pkey on t3 - -> Materialize - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(14 rows) + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t2_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t1_5.id, $5123, $5124, ..., $6145])) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) +(51 rows) -/*+Leading((((t1 t2) t3) t4))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; +/*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/ +EXPLAIN (COSTS false) +WITH c1_1(id) AS ( +SELECT max(t1_5.id) FROM t1 t1_5, t2 t2_5, t3 t3_5 WHERE t1_5.id = t2_5.id AND t2_5.id = t3_5.id +) +SELECT t1_1.id, ( +SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t2_2.id = t3_2.id +) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( +SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id +) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +); LOG: pg_hint_plan: used hint: -Leading((((t1 t2) t3) t4)) +MergeJoin(t1_3 t3_3) +Leading(t3_5 t2_5 t1_5) +Leading(t3_2 t2_2 t1_2) +Leading(t3_4 t2_4 t1_4) +Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1) not used hint: +HashJoin(t1_1 t3_1) +NestLoop(t1_2 t2_2) +NestLoop(t1_4 t2_4) +NestLoop(t1_5 t2_5) duplication hint: error hint: - QUERY PLAN --------------------------------------------------- + QUERY PLAN +--------------------------------------------------------------------------------------------------------------- Nested Loop + InitPlan 1 (returns $2048) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t2_2.id = t1_2.id) + -> YB Batched Nested Loop Join + Join Filter: (t2_2.id = t3_2.id) + -> Seq Scan on t3 t3_2 + -> Index Scan using t2_pkey on t2 t2_2 + Index Cond: (id = ANY (ARRAY[t3_2.id, $1, $2, ..., $1023])) + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t2_2.id, $1025, $1026, ..., $2047])) + InitPlan 2 (returns $4097) + -> Aggregate + -> YB Batched Nested Loop Join + Join Filter: (t2_4.id = t1_4.id) + -> YB Batched Nested Loop Join + Join Filter: (t2_4.id = t3_4.id) + -> Seq Scan on t3 t3_4 + -> Index Scan using t2_pkey on t2 t2_4 + Index Cond: (id = ANY (ARRAY[t3_4.id, $2050, $2051, ..., $3072])) + -> Index Scan using t1_pkey on t1 t1_4 + Index Cond: (id = ANY (ARRAY[t2_4.id, $3074, $3075, ..., $4096])) + -> Index Scan using t1_pkey on t1 t1_1 + Index Cond: (id = $4097) -> Nested Loop - Join Filter: (t1.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 - -> Index Scan using t4_pkey on t4 - Index Cond: (id = t3.id) -(12 rows) + -> Index Scan using t2_pkey on t2 t2_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t3_pkey on t3 t3_1 + Index Cond: (id = $4097) + -> Nested Loop + -> Aggregate + Filter: (max(t1_5.id) = $4097) + -> YB Batched Nested Loop Join + Join Filter: (t2_5.id = t1_5.id) + -> YB Batched Nested Loop Join + Join Filter: (t2_5.id = t3_5.id) + -> Seq Scan on t3 t3_5 + -> Index Scan using t2_pkey on t2 t2_5 + Index Cond: (id = ANY (ARRAY[t3_5.id, $4099, $4100, ..., $5121])) + -> Index Scan using t1_pkey on t1 t1_5 + Index Cond: (id = ANY (ARRAY[t2_5.id, $5123, $5124, ..., $6145])) + -> Nested Loop + -> Index Scan using t1_pkey on t1 t1_3 + Index Cond: (id = $4097) + -> Nested Loop + -> Index Scan using t2_pkey on t2 t2_3 + Index Cond: (id = $4097) + -> Index Scan using t3_pkey on t3 t3_3 + Index Cond: (id = $4097) +(51 rows) -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; - QUERY PLAN --------------------------------------------------------- - Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 - -> Hash - -> Hash Join - Hash Cond: (t2.id = t1.id) - -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) -(10 rows) +-- ambiguous error +EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id; + QUERY PLAN +--------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t1_1.id) + -> Seq Scan on t1 t1_1 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t1_1.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) +(9 rows) -/*+Leading(((t1 t2) t3))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +/*+MergeJoin(t1 t2)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id; +INFO: pg_hint_plan: hint syntax error at or near "MergeJoin(t1 t2)" +DETAIL: Relation name "t1" is ambiguous. LOG: pg_hint_plan: used hint: -Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: +MergeJoin(t1 t2) - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t2.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) + QUERY PLAN +--------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t1_1.id) + -> Seq Scan on t1 t1_1 -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 + Index Cond: (id = ANY (ARRAY[t1_1.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) (9 rows) -/*+Leading((t1 (t2 t3)))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +/*+Leading(t1 t2 t1)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, s0.t1, t2 WHERE public.t1.id = s0.t1.id AND public.t1.id = t2.id; +INFO: pg_hint_plan: hint syntax error at or near "Leading(t1 t2 t1)" +DETAIL: Relation name "t1" is ambiguous. LOG: pg_hint_plan: used hint: -Leading((t1 (t2 t3))) not used hint: duplication hint: error hint: +Leading(t1 t2 t1) - QUERY PLAN --------------------------------------------- - Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Hash Join - Hash Cond: (t2.val = t3.val) - -> Seq Scan on t2 - -> Hash - -> Seq Scan on t3 -(10 rows) + QUERY PLAN +--------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t1_1.id) + -> Seq Scan on t1 t1_1 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t1_1.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) +(9 rows) -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; - QUERY PLAN --------------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Nested Loop - Join Filter: (t1.val = t3.val) - -> Index Scan using t3_pkey on t3 - -> Materialize - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 +-- identifier length test +EXPLAIN (COSTS false) SELECT * FROM t1 "123456789012345678901234567890123456789012345678901234567890123" JOIN t2 ON ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) JOIN t3 ON (t2.id = t3.id); + QUERY PLAN +---------------------------------------------------------------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id) + -> Seq Scan on t3 + -> Index Scan using t1_pkey on t1 "123456789012345678901234567890123456789012345678901234567890123" + Index Cond: (id = ANY (ARRAY[t3.id, $1, $2, ..., $1023])) -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(14 rows) + Index Cond: (id = ANY (ARRAY["123456789012345678901234567890123456789012345678901234567890123".id, $1025, $1026, ..., $2047])) +(9 rows) -/*+Leading(((t1 t2) (t3 t4)))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; +/*+ +Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3) +SeqScan(123456789012345678901234567890123456789012345678901234567890123) +MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2) +Set(123456789012345678901234567890123456789012345678901234567890123 1) +*/ +EXPLAIN (COSTS false) SELECT * FROM t1 "123456789012345678901234567890123456789012345678901234567890123" JOIN t2 ON ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) JOIN t3 ON (t2.id = t3.id); +INFO: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" LOG: pg_hint_plan: used hint: -Leading(((t1 t2) (t3 t4))) +SeqScan(123456789012345678901234567890123456789012345678901234567890123) +MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2) +Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3) not used hint: duplication hint: error hint: +Set(123456789012345678901234567890123456789012345678901234567890123 1) - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t1.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 + QUERY PLAN +---------------------------------------------------------------------------------------------------- + Merge Join + Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id) -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 + Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) -> Sort - Sort Key: t4.id - -> Seq Scan on t4 -(14 rows) + Sort Key: "123456789012345678901234567890123456789012345678901234567890123".id + -> Seq Scan on t1 "123456789012345678901234567890123456789012345678901234567890123" + -> Sort + Sort Key: t2.id + -> Seq Scan on t2 + -> Sort + Sort Key: t3.id + -> Seq Scan on t3 +(13 rows) -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); - QUERY PLAN --------------------------------------------------------------------- - Hash Join - Hash Cond: (t2.val = t3.val) - InitPlan 1 (returns $1) - -> Limit - -> Sort - Sort Key: t1_2.id - -> Nested Loop - -> Index Scan using t2_val on t2 t2_2 - Index Cond: (val > 100) - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) +/*+ +Leading(1234567890123456789012345678901234567890123456789012345678901234 t2 t3) +SeqScan(1234567890123456789012345678901234567890123456789012345678901234) +MergeJoin(1234567890123456789012345678901234567890123456789012345678901234 t2) +Set(1234567890123456789012345678901234567890123456789012345678901234 1) +Set(cursor_tuple_fraction 0.1234567890123456789012345678901234567890123456789012345678901234) +*/ +EXPLAIN (COSTS false) SELECT * FROM t1 "1234567890123456789012345678901234567890123456789012345678901234" JOIN t2 ON ("1234567890123456789012345678901234567890123456789012345678901234".id = t2.id) JOIN t3 ON (t2.id = t3.id); +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +INFO: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" +LOG: pg_hint_plan: +used hint: +SeqScan(123456789012345678901234567890123456789012345678901234567890123) +MergeJoin(123456789012345678901234567890123456789012345678901234567890123 t2) +Leading(123456789012345678901234567890123456789012345678901234567890123 t2 t3) +Set(cursor_tuple_fraction 0.1234567890123456789012345678901234567890123456789012345678901234) +not used hint: +duplication hint: +error hint: +Set(123456789012345678901234567890123456789012345678901234567890123 1) + + QUERY PLAN +---------------------------------------------------------------------------------------------------- + Merge Join + Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t3.id) -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < $1) - -> Index Scan using t2_pkey on t2 - -> Hash + Merge Cond: ("123456789012345678901234567890123456789012345678901234567890123".id = t2.id) + -> Sort + Sort Key: "123456789012345678901234567890123456789012345678901234567890123".id + -> Seq Scan on t1 "123456789012345678901234567890123456789012345678901234567890123" + -> Sort + Sort Key: t2.id + -> Seq Scan on t2 + -> Sort + Sort Key: t3.id -> Seq Scan on t3 -(18 rows) +(13 rows) + +SET "123456789012345678901234567890123456789012345678901234567890123" TO 1; +ERROR: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" +SET "1234567890123456789012345678901234567890123456789012345678901234" TO 1; +NOTICE: identifier "1234567890123456789012345678901234567890123456789012345678901234" will be truncated to "123456789012345678901234567890123456789012345678901234567890123" +ERROR: unrecognized configuration parameter "123456789012345678901234567890123456789012345678901234567890123" +SET cursor_tuple_fraction TO 1234567890123456789012345678901234567890123456789012345678901234; +ERROR: 1.23457e+63 is outside the valid range for parameter "cursor_tuple_fraction" (0 .. 1) +-- multi error +/*+ Set(enable_seqscan 100)Set(seq_page_cost on)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; +INFO: parameter "enable_seqscan" requires a Boolean value +INFO: invalid value for parameter "seq_page_cost": "on" +LOG: pg_hint_plan: +used hint: +not used hint: +duplication hint: +error hint: +Set(enable_seqscan 100) +Set(seq_page_cost on) -/*+Leading(((t1 t2) t3)) Leading(((t3 t1) t2))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t1.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); -INFO: pg_hint_plan: hint syntax error at or near "Leading(((t1 t2) t3)) Leading(((t3 t1) t2))" -DETAIL: Conflict leading hint. + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(5 rows) + +-- debug log of candidate index to use IndexScan +EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 + Index Cond: (id = 1) +(2 rows) + +/*+IndexScan(t5 t5_id2)*/ +EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; +LOG: available indexes for IndexScan(t5): t5_id2 LOG: pg_hint_plan: used hint: -Leading(((t3 t1) t2)) +IndexScan(t5 t5_id2) not used hint: duplication hint: -Leading(((t1 t2) t3)) error hint: - QUERY PLAN --------------------------------------------------------------------- - Hash Join - Hash Cond: (t1.id = t2.id) - InitPlan 1 (returns $1) - -> Limit - -> Sort - Sort Key: t1_2.id - -> Nested Loop - -> Index Scan using t2_val on t2 t2_2 - Index Cond: (val > 100) - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Hash Join - Hash Cond: (t3.val = t1.val) - -> Seq Scan on t3 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < $1) - -> Hash - -> Seq Scan on t2 -(19 rows) + QUERY PLAN +------------------------------- + Index Scan using t5_id2 on t5 + Index Cond: (id = 1) +(2 rows) -/*+Leading(((t1 t2) t3)) Leading((t1_2 t2_2))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); +/*+IndexScan(t5 no_exist)*/ +EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; +LOG: available indexes for IndexScan(t5): LOG: pg_hint_plan: used hint: -Leading(((t1 t2) t3)) -Leading((t1_2 t2_2)) not used hint: +IndexScan(t5 no_exist) duplication hint: error hint: - QUERY PLAN --------------------------------------------------------------- - Hash Join - Hash Cond: (t2.val = t3.val) - InitPlan 1 (returns $0) - -> Limit - -> Merge Join - Merge Cond: (t1_2.id = t2_2.id) - -> Index Only Scan using t1_pkey on t1 t1_2 - -> Sort - Sort Key: t2_2.id - -> Index Scan using t2_val on t2 t2_2 - Index Cond: (val > 100) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < $0) - -> Index Scan using t2_pkey on t2 - -> Hash - -> Seq Scan on t3 -(18 rows) + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 + Index Cond: (id = 1) +(2 rows) -/*+Leading(((((t1 t2) t3) t1_2) t2_2))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); +/*+IndexScan(t5 t5_id1 t5_id2)*/ +EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; +LOG: available indexes for IndexScan(t5): t5_id2 t5_id1 LOG: pg_hint_plan: used hint: +IndexScan(t5 t5_id1 t5_id2) not used hint: -Leading(((((t1 t2) t3) t1_2) t2_2)) duplication hint: error hint: - QUERY PLAN --------------------------------------------------------------------- - Hash Join - Hash Cond: (t2.val = t3.val) - InitPlan 1 (returns $1) - -> Limit - -> Sort - Sort Key: t1_2.id - -> Nested Loop - -> Index Scan using t2_val on t2 t2_2 - Index Cond: (val > 100) - -> Index Only Scan using t1_pkey on t1 t1_2 - Index Cond: (id = t2_2.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < $1) - -> Index Scan using t2_pkey on t2 - -> Hash - -> Seq Scan on t3 -(18 rows) + QUERY PLAN +------------------------------- + Index Scan using t5_id2 on t5 + Index Cond: (id = 1) +(2 rows) --- Specified outer/inner leading hint and join method hint at the same time -/*+Leading(((t1 t2) t3))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +/*+IndexScan(t5 no_exist t5_id2)*/ +EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; +LOG: available indexes for IndexScan(t5): t5_id2 LOG: pg_hint_plan: used hint: -Leading(((t1 t2) t3)) +IndexScan(t5 no_exist t5_id2) not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t2.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 -(9 rows) + QUERY PLAN +------------------------------- + Index Scan using t5_id2 on t5 + Index Cond: (id = 1) +(2 rows) -/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +/*+IndexScan(t5 no_exist5 no_exist2)*/ +EXPLAIN (COSTS false) SELECT * FROM t5 WHERE t5.id = 1; +LOG: available indexes for IndexScan(t5): LOG: pg_hint_plan: used hint: -MergeJoin(t1 t2) -Leading(((t1 t2) t3)) not used hint: +IndexScan(t5 no_exist5 no_exist2) duplication hint: error hint: - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t2.val = t3.val) - -> Merge Join - Merge Cond: (t1.id = t2.id) + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 + Index Cond: (id = 1) +(2 rows) + +-- outer inner +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Index Scan using t2_pkey on t2 - -> Seq Scan on t3 -(8 rows) + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t3 +(10 rows) -/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3)*/ +/*+Leading((t1))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +INFO: pg_hint_plan: hint syntax error at or near "Leading((t1))" +DETAIL: Leading hint requires two sets of relations when parentheses nests. LOG: pg_hint_plan: used hint: -MergeJoin(t1 t2 t3) -Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: +Leading((t1)) - QUERY PLAN --------------------------------------------------- - Merge Join - Merge Cond: (t2.val = t3.val) - -> Sort - Sort Key: t2.val - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Sort - Sort Key: t3.val + QUERY PLAN +------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash -> Seq Scan on t3 -(13 rows) +(10 rows) -/*+Leading(((t1 t2) t3)) MergeJoin(t1 t3)*/ +/*+Leading((t1 t2))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading(((t1 t2) t3)) +Leading((t1 t2)) not used hint: -MergeJoin(t1 t3) duplication hint: error hint: - QUERY PLAN --------------------------------------------- + QUERY PLAN +---------------------------------------- Nested Loop Join Filter: (t2.val = t3.val) -> Hash Join Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + -> Seq Scan on t1 + Remote Filter: (id < 10) -> Hash -> Seq Scan on t2 - -> Seq Scan on t3 -(9 rows) - -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; - QUERY PLAN --------------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Nested Loop - Join Filter: (t1.val = t3.val) - -> Index Scan using t3_pkey on t3 - -> Materialize - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t1.id) -(14 rows) - -/*+Leading(((t1 t2) t3)) MergeJoin(t3 t4)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -Leading(((t1 t2) t3)) -not used hint: -MergeJoin(t3 t4) -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------------- - Nested Loop - Join Filter: (t3.id = t4.id) - -> Nested Loop - Join Filter: (t1.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 + -> Materialize -> Seq Scan on t3 - -> Seq Scan on t4 -(12 rows) - -/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3 t4)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; -LOG: pg_hint_plan: -used hint: -MergeJoin(t1 t2 t3 t4) -Leading(((t1 t2) t3)) -not used hint: -duplication hint: -error hint: - - QUERY PLAN --------------------------------------------------------- - Merge Join - Merge Cond: (t3.id = t4.id) - -> Sort - Sort Key: t3.id - -> Nested Loop - Join Filter: (t1.val = t3.val) - -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) - -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 -(16 rows) +(10 rows) -/*+ Leading ( ( t1 ( t2 t3 ) ) ) */ +/*+Leading((t1 t2 t3))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +INFO: pg_hint_plan: hint syntax error at or near "Leading((t1 t2 t3))" +DETAIL: Leading hint requires two sets of relations when parentheses nests. LOG: pg_hint_plan: used hint: -Leading((t1 (t2 t3))) not used hint: duplication hint: error hint: +Leading((t1 t2 t3)) - QUERY PLAN --------------------------------------------- + QUERY PLAN +------------------------------------------------------------------------- Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) -> Hash - -> Hash Join - Hash Cond: (t2.val = t3.val) - -> Seq Scan on t2 - -> Hash - -> Seq Scan on t3 + -> Seq Scan on t3 (10 rows) -/*+Leading((t1(t2 t3)))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) +(6 rows) + +/*+Leading((t1 t2))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading((t1 (t2 t3))) +Leading((t1 t2)) not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------- + QUERY PLAN +---------------------------------- Hash Join Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + -> Seq Scan on t1 + Remote Filter: (id < 10) -> Hash - -> Hash Join - Hash Cond: (t2.val = t3.val) - -> Seq Scan on t2 - -> Hash - -> Seq Scan on t3 + -> Seq Scan on t2 +(6 rows) + +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t3 (10 rows) -/*+Leading(("t1(t2" "t3)"))*/ +/*+Leading(((t1 t2) t3))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: +Leading(((t1 t2) t3)) not used hint: -Leading(("t1(t2" "t3)")) duplication hint: error hint: - QUERY PLAN --------------------------------------------------------- + QUERY PLAN +---------------------------------------- Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 - -> Hash - -> Hash Join - Hash Cond: (t2.id = t1.id) + Hash Cond: (t2.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash -> Seq Scan on t2 - -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + -> Hash + -> Seq Scan on t3 (10 rows) -/*+ Leading ( ( ( t1 t2 ) t3 ) ) */ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t1.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t4.id) + -> Seq Scan on t4 + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t4.id, $1025, $1026, ..., $2047])) +(14 rows) + +/*+Leading((((t1 t2) t3) t4))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading(((t1 t2) t3)) +Leading((((t1 t2) t3) t4)) not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t2.val = t3.val) + QUERY PLAN +---------------------------------------------- + Hash Join + Hash Cond: (t3.id = t4.id) -> Hash Join - Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + Hash Cond: (t1.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 -> Hash - -> Seq Scan on t2 - -> Seq Scan on t3 -(9 rows) + -> Seq Scan on t3 + -> Hash + -> Seq Scan on t4 +(14 rows) -/*+Leading(((t1 t2)t3))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t3 +(10 rows) + +/*+Leading(((t1 t2) t3))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: @@ -6326,927 +2851,836 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------- - Nested Loop - Join Filter: (t2.val = t3.val) + QUERY PLAN +---------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) -> Hash Join Hash Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + -> Seq Scan on t1 + Remote Filter: (id < 10) -> Hash -> Seq Scan on t2 - -> Seq Scan on t3 -(9 rows) + -> Hash + -> Seq Scan on t3 +(10 rows) -/*+Leading(("(t1" "t2)t3"))*/ +/*+Leading((t1 (t2 t3)))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: +Leading((t1 (t2 t3))) not used hint: -Leading(("(t1" "t2)t3")) duplication hint: error hint: - QUERY PLAN --------------------------------------------------------- + QUERY PLAN +-------------------------------------------- Hash Join - Hash Cond: (t3.val = t2.val) - -> Seq Scan on t3 + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) -> Hash -> Hash Join - Hash Cond: (t2.id = t1.id) + Hash Cond: (t2.val = t3.val) -> Seq Scan on t2 -> Hash - -> Index Scan using t1_pkey on t1 - Index Cond: (id < 10) + -> Seq Scan on t3 (10 rows) -/*+Leading((t1(t2(t3(t4 t5)))))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; -LOG: pg_hint_plan: -used hint: -Leading((t1 (t2 (t3 (t4 t5))))) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Materialize - -> Merge Join - Merge Cond: (t2.id = t3.id) - -> Index Scan using t2_pkey on t2 - -> Materialize - -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 - -> Materialize - -> Merge Join - Merge Cond: (t4.id = t5.id) - -> Index Scan using t4_pkey on t4 - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 -(16 rows) +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t1.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t4.id) + -> Seq Scan on t4 + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t4.id, $1025, $1026, ..., $2047])) +(14 rows) -/*+Leading((t5(t4(t3(t2 t1)))))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +/*+Leading(((t1 t2) (t3 t4)))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading((t5 (t4 (t3 (t2 t1))))) +Leading(((t1 t2) (t3 t4))) not used hint: duplication hint: error hint: - QUERY PLAN --------------------------------------------------------------------------- + QUERY PLAN +------------------------------------------ Hash Join - Hash Cond: (t5.id = t1.id) - -> Seq Scan on t5 + Hash Cond: (t1.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 -> Hash - -> Merge Join - Merge Cond: (t4.id = t1.id) - -> Sort - Sort Key: t4.id + -> Hash Join + Hash Cond: (t3.id = t4.id) + -> Seq Scan on t3 + -> Hash -> Seq Scan on t4 - -> Materialize - -> Merge Join - Merge Cond: (t3.id = t1.id) - -> Sort - Sort Key: t3.id - -> Seq Scan on t3 - -> Materialize - -> Merge Join - Merge Cond: (t2.id = t1.id) - -> Index Scan using t2_pkey on t2 - -> Index Scan using t1_pkey on t1 +(14 rows) + +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); + QUERY PLAN +----------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + InitPlan 1 (returns $1024) + -> Limit + -> Sort + Sort Key: t1_2.id + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> Seq Scan on t2 t2_2 + Remote Filter: (val > 100) + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t2_2.id, $1, $2, ..., $1023])) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1026, $1027, ..., $2048])) + Remote Filter: (id < $1024) + -> Hash + -> Seq Scan on t3 (20 rows) -/*+Leading(((((t1 t2)t3)t4)t5))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +/*+Leading(((t1 t2) t3)) Leading(((t3 t1) t2))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t1.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); +INFO: pg_hint_plan: hint syntax error at or near "Leading(((t1 t2) t3)) Leading(((t3 t1) t2))" +DETAIL: Conflict leading hint. LOG: pg_hint_plan: used hint: -Leading(((((t1 t2) t3) t4) t5)) +Leading(((t3 t1) t2)) not used hint: duplication hint: +Leading(((t1 t2) t3)) error hint: - QUERY PLAN ----------------------------------------------------------------------------------------------- - Nested Loop - -> Merge Join - Merge Cond: (t1.id = t4.id) - -> Merge Join - Merge Cond: (t1.id = t3.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Sort - Sort Key: t3.id - -> Seq Scan on t3 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - Index Cond: (id = t1.id) -(17 rows) + QUERY PLAN +----------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t1.id = t2.id) + InitPlan 1 (returns $1024) + -> Limit + -> Sort + Sort Key: t1_2.id + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> Seq Scan on t2 t2_2 + Remote Filter: (val > 100) + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t2_2.id, $1, $2, ..., $1023])) + -> Hash Join + Hash Cond: (t3.val = t1.val) + -> Seq Scan on t3 + -> Hash + -> Seq Scan on t1 + Remote Filter: (id < $1024) + -> Hash + -> Seq Scan on t2 +(20 rows) -/*+Leading(((((t5 t4)t3)t2)t1))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +/*+Leading(((t1 t2) t3)) Leading((t1_2 t2_2))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); LOG: pg_hint_plan: used hint: -Leading(((((t5 t4) t3) t2) t1)) +Leading(((t1 t2) t3)) +Leading((t1_2 t2_2)) not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------------------------------------------------------------------- - Nested Loop - Join Filter: (t2.id = t1.id) - -> Nested Loop - Join Filter: (t3.id = t2.id) - -> Merge Join - Merge Cond: (t4.id = t3.id) - -> Merge Join - Merge Cond: (t5.id = t4.id) - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - -> Index Scan using t2_pkey on t2 - Index Cond: (id = t5.id) - -> Index Scan using t1_pkey on t1 - Index Cond: (id = t5.id) -(17 rows) + QUERY PLAN +-------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + InitPlan 1 (returns $0) + -> Limit + -> Sort + Sort Key: t1_2.id + -> Hash Join + Hash Cond: (t1_2.id = t2_2.id) + -> Seq Scan on t1 t1_2 + -> Hash + -> Seq Scan on t2 t2_2 + Remote Filter: (val > 100) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < $0) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(20 rows) -/*+Leading(((t1 t2)(t3(t4 t5))))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +/*+Leading(((((t1 t2) t3) t1_2) t2_2))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < ( SELECT t1_2.id FROM t1 t1_2, t2 t2_2 WHERE t1_2.id = t2_2.id AND t2_2.val > 100 ORDER BY t1_2.id LIMIT 1); LOG: pg_hint_plan: used hint: -Leading(((t1 t2) (t3 (t4 t5)))) not used hint: +Leading(((((t1 t2) t3) t1_2) t2_2)) duplication hint: error hint: - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: (t1.id = t3.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 - -> Materialize - -> Merge Join - Merge Cond: (t3.id = t4.id) - -> Index Scan using t3_pkey on t3 - -> Materialize - -> Merge Join - Merge Cond: (t4.id = t5.id) - -> Index Scan using t4_pkey on t4 - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 -(15 rows) + QUERY PLAN +----------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + InitPlan 1 (returns $1024) + -> Limit + -> Sort + Sort Key: t1_2.id + -> YB Batched Nested Loop Join + Join Filter: (t1_2.id = t2_2.id) + -> Seq Scan on t2 t2_2 + Remote Filter: (val > 100) + -> Index Scan using t1_pkey on t1 t1_2 + Index Cond: (id = ANY (ARRAY[t2_2.id, $1, $2, ..., $1023])) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1026, $1027, ..., $2048])) + Remote Filter: (id < $1024) + -> Hash + -> Seq Scan on t3 +(20 rows) -/*+Leading(((t5 t4)(t3(t2 t1))))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +-- Specified outer/inner leading hint and join method hint at the same time +/*+Leading(((t1 t2) t3))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading(((t5 t4) (t3 (t2 t1)))) +Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: (t4.id = t1.id) - -> Merge Join - Merge Cond: (t5.id = t4.id) - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - -> Materialize - -> Merge Join - Merge Cond: (t3.id = t1.id) - -> Sort - Sort Key: t3.id - -> Seq Scan on t3 - -> Materialize - -> Merge Join - Merge Cond: (t2.id = t1.id) - -> Index Scan using t2_pkey on t2 - -> Index Scan using t1_pkey on t1 -(19 rows) + QUERY PLAN +---------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(10 rows) -/*+Leading((((t1 t2)t3)(t4 t5)))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading((((t1 t2) t3) (t4 t5))) +MergeJoin(t1 t2) +Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------------------------------------------------------------- - Merge Join - Merge Cond: (t1.id = t4.id) + QUERY PLAN +---------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) -> Merge Join - Merge Cond: (t1.id = t3.id) - -> Merge Join - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 - -> Index Scan using t2_pkey on t2 + Merge Cond: (t1.id = t2.id) -> Sort - Sort Key: t3.id - -> Seq Scan on t3 - -> Materialize - -> Merge Join - Merge Cond: (t4.id = t5.id) - -> Index Scan using t4_pkey on t4 - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 -(16 rows) + Sort Key: t1.id + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Sort + Sort Key: t2.id + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(13 rows) -/*+Leading((((t5 t4)t3)(t2 t1)))*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -Leading((((t5 t4) t3) (t2 t1))) +MergeJoin(t1 t2 t3) +Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------------------------------------------------------------- + QUERY PLAN +---------------------------------------------- Merge Join - Merge Cond: (t3.id = t1.id) - -> Merge Join - Merge Cond: (t4.id = t3.id) - -> Merge Join - Merge Cond: (t5.id = t4.id) - -> Index Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - -> Sort - Sort Key: t4.id - -> Seq Scan on t4 - -> Index Scan using t3_pkey on t3 - -> Materialize - -> Merge Join - Merge Cond: (t2.id = t1.id) - -> Index Scan using t2_pkey on t2 - -> Index Scan using t1_pkey on t1 -(16 rows) - --- inherite table test to specify the index's name -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1 p2_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(9 rows) + Merge Cond: (t2.val = t3.val) + -> Sort + Sort Key: t2.val + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Sort + Sort Key: t3.val + -> Seq Scan on t3 +(13 rows) -/*+IndexScan(p2 p2_pkey)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_pkey -LOG: available indexes for IndexScan(p2_c1): p2_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey +/*+Leading(((t1 t2) t3)) MergeJoin(t1 t3)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_pkey) +Leading(((t1 t2) t3)) not used hint: +MergeJoin(t1 t3) duplication hint: error hint: - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p2_pkey on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_pkey on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +---------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(10 rows) -/*+IndexScan(p2 p2_id_val_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_id_val_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; + QUERY PLAN +------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t1.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t4.id) + -> Seq Scan on t4 + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t4.id, $1025, $1026, ..., $2047])) +(14 rows) + +/*+Leading(((t1 t2) t3)) MergeJoin(t3 t4)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_id_val_idx) +Leading(((t1 t2) t3)) not used hint: +MergeJoin(t3 t4) duplication hint: error hint: - QUERY PLAN -------------------------------------------------------------- - Append - -> Index Scan using p2_id_val_idx on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t3.id = t4.id) + -> Hash Join + Hash Cond: (t1.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 + -> Memoize + Cache Key: t3.id + Cache Mode: logical + -> Index Scan using t4_pkey on t4 + Index Cond: (id = ANY (ARRAY[t3.id, $1, $2, ..., $1023])) +(17 rows) -/*+IndexScan(p2 p2_val_id_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_val_id_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_val_id_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_val_id_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_val_id_idx +/*+Leading(((t1 t2) t3)) MergeJoin(t1 t2 t3 t4)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t3.id = t4.id AND t1.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_val_id_idx) +MergeJoin(t1 t2 t3 t4) +Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------------- - Append - -> Index Scan using p2_val_id_idx on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_val_id_idx on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_val_id_idx on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_val_id_idx on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) - -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; - QUERY PLAN ------------------------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1 p2_2 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c2 p2_3 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3 p2_4 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c4 p2_5 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) -(19 rows) + QUERY PLAN +---------------------------------------------------- + Merge Join + Merge Cond: (t3.id = t4.id) + -> Sort + Sort Key: t3.id + -> Hash Join + Hash Cond: (t1.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 + -> Sort + Sort Key: t4.id + -> Seq Scan on t4 +(17 rows) --- 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): -LOG: available indexes for IndexScan(p2_c2): -LOG: available indexes for IndexScan(p2_c3): -LOG: available indexes for IndexScan(p2_c4): -LOG: available indexes for IndexScan(p2_c1_c1): -LOG: available indexes for IndexScan(p2_c1_c2): -LOG: available indexes for IndexScan(p2_c3_c1): -LOG: available indexes for IndexScan(p2_c3_c2): +/*+ Leading ( ( t1 ( t2 t3 ) ) ) */ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: +Leading((t1 (t2 t3))) not used hint: -IndexScan(p2 p2_val) duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1 p2_2 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c2 p2_3 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3 p2_4 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c4 p2_5 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) -(19 rows) - -/*+IndexScan(p2 p2_pkey)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_pkey -LOG: available indexes for IndexScan(p2_c1): p2_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey + QUERY PLAN +-------------------------------------------- + Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Hash Join + Hash Cond: (t2.val = t3.val) + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(10 rows) + +/*+Leading((t1(t2 t3)))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_pkey) +Leading((t1 (t2 t3))) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p2_pkey on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_pkey on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +-------------------------------------------- + Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Hash Join + Hash Cond: (t2.val = t3.val) + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(10 rows) -/*+IndexScan(p2 p2_id2_val)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_id2_val -LOG: available indexes for IndexScan(p2_c1): p2_c1_id2_val -LOG: available indexes for IndexScan(p2_c1_c1): -LOG: available indexes for IndexScan(p2_c1_c2): +/*+Leading(("t1(t2" "t3)"))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_id2_val) not used hint: +Leading(("t1(t2" "t3)")) duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Index Scan using p2_id2_val on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_id2_val on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Seq Scan on p2_c1_c1 p2_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(11 rows) - -/*+IndexScan(p2 p2_val2_id)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_val2_id -LOG: available indexes for IndexScan(p2_c1): -LOG: available indexes for IndexScan(p2_c1_c1): -LOG: available indexes for IndexScan(p2_c1_c2): + QUERY PLAN +------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t3 +(10 rows) + +/*+ Leading ( ( ( t1 t2 ) t3 ) ) */ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_val2_id) +Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Index Scan using p2_val2_id on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Seq Scan on p2_c1 p2_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) + QUERY PLAN +---------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 (10 rows) -/*+IndexScan(p2 p2_pkey)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_pkey -LOG: available indexes for IndexScan(p2_c1): p2_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey +/*+Leading(((t1 t2)t3))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_pkey) +Leading(((t1 t2) t3)) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p2_pkey on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_pkey on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +---------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 +(10 rows) -/*+IndexScan(p2 p2_c1_id_val_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): -LOG: available indexes for IndexScan(p2_c1_c2): +/*+Leading(("(t1" "t2)t3"))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3 WHERE t1.id = t2.id AND t2.val = t3.val AND t1.id < 10; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_c1_id_val_idx) not used hint: +Leading(("(t1" "t2)t3")) duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Seq Scan on p2_c1_c1 p2_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) + QUERY PLAN +------------------------------------------------------------------------- + Hash Join + Hash Cond: (t2.val = t3.val) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) + Remote Filter: (id < 10) + -> Hash + -> Seq Scan on t3 (10 rows) -/*+IndexScan(p2 no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): -LOG: available indexes for IndexScan(p2_c1): -LOG: available indexes for IndexScan(p2_c1_c1): -LOG: available indexes for IndexScan(p2_c1_c2): +/*+Leading((t1(t2(t3(t4 t5)))))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: +Leading((t1 (t2 (t3 (t4 t5))))) not used hint: -IndexScan(p2 no_exist) duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1 p2_2 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(9 rows) + QUERY PLAN +------------------------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + -> Hash + -> Hash Join + Hash Cond: (t2.id = t3.id) + -> Seq Scan on t2 + -> Hash + -> Hash Join + Hash Cond: (t3.id = t4.id) + -> Seq Scan on t3 + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t4.id = t5.id) + -> Seq Scan on t4 + -> Index Scan using t5_pkey on t5 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) +(17 rows) -/*+IndexScan(p2 p2_pkey p2_c1_id_val_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_pkey -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx p2_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey +/*+Leading((t5(t4(t3(t2 t1)))))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_pkey p2_c1_id_val_idx) +Leading((t5 (t4 (t3 (t2 t1))))) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p2_pkey on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +------------------------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t5.id = t1.id) + -> Seq Scan on t5 + -> Hash + -> Merge Join + Merge Cond: (t4.id = t1.id) + -> Sort + Sort Key: t4.id + -> Seq Scan on t4 + -> Sort + Sort Key: t1.id + -> Hash Join + Hash Cond: (t3.id = t1.id) + -> Seq Scan on t3 + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(20 rows) -/*+IndexScan(p2 p2_pkey no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_pkey -LOG: available indexes for IndexScan(p2_c1): p2_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey +/*+Leading(((((t1 t2)t3)t4)t5))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_pkey no_exist) +Leading(((((t1 t2) t3) t4) t5)) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p2_pkey on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_pkey on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t5.id) + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t4.id) + -> Hash Join + Hash Cond: (t1.id = t3.id) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 + -> Index Scan using t4_pkey on t4 + Index Cond: (id = ANY (ARRAY[t1.id, $1, $2, ..., $1023])) + -> Index Scan using t5_pkey on t5 + Index Cond: (id = ANY (ARRAY[t1.id, $1025, $1026, ..., $2047])) +(17 rows) -/*+IndexScan(p2 p2_c1_id_val_idx no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): -LOG: available indexes for IndexScan(p2_c1_c2): +/*+Leading(((((t5 t4)t3)t2)t1))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_c1_id_val_idx no_exist) +Leading(((((t5 t4) t3) t2) t1)) not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Seq Scan on p2_c1_c1 p2_3 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_4 - Filter: ((id >= 50) AND (id <= 51) AND (ctid = '(1,1)'::tid)) -(10 rows) + QUERY PLAN +------------------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t2.id = t1.id) + -> YB Batched Nested Loop Join + Join Filter: (t3.id = t2.id) + -> YB Batched Nested Loop Join + Join Filter: (t4.id = t3.id) + -> Hash Join + Hash Cond: (t5.id = t4.id) + -> Seq Scan on t5 + -> Hash + -> Seq Scan on t4 + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t5.id, $1, $2, ..., $1023])) + -> Index Scan using t2_pkey on t2 + Index Cond: (id = ANY (ARRAY[t5.id, $1025, $1026, ..., $2047])) + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t5.id, $2049, $2050, ..., $3071])) +(17 rows) -/*+IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_pkey -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx p2_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_pkey -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_pkey +/*+Leading(((t1 t2)(t3(t4 t5))))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist) +Leading(((t1 t2) (t3 (t4 t5)))) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p2_pkey on p2 p2_1 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_pkey on p2_c1_c1 p2_3 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_pkey on p2_c1_c2 p2_4 - Index Cond: ((id >= 50) AND (id <= 51)) - Filter: (ctid = '(1,1)'::tid) -(13 rows) + QUERY PLAN +------------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t1.id = t3.id) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + -> Hash + -> Seq Scan on t2 + -> Hash + -> Hash Join + Hash Cond: (t3.id = t4.id) + -> Seq Scan on t3 + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t4.id = t5.id) + -> Seq Scan on t4 + -> Index Scan using t5_pkey on t5 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) +(17 rows) -/*+IndexScan(p2 p2_val_idx)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_val_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_val_idx -LOG: available indexes for IndexScan(p2_c2): p2_c2_val_idx -LOG: available indexes for IndexScan(p2_c3): p2_c3_val_idx -LOG: available indexes for IndexScan(p2_c4): p2_c4_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_val_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_val_idx -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_val_idx -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_val_idx +/*+Leading(((t5 t4)(t3(t2 t1))))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_val_idx) +Leading(((t5 t4) (t3 (t2 t1)))) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------------------- - Append - -> Index Scan using p2_val_idx on p2 p2_1 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_val_idx on p2_c1 p2_2 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c2_val_idx on p2_c2 p2_3 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c3_val_idx on p2_c3 p2_4 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c4_val_idx on p2_c4 p2_5 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_val_idx on p2_c1_c1 p2_6 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_val_idx on p2_c1_c2 p2_7 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c3_c1_val_idx on p2_c3_c1 p2_8 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c3_c2_val_idx on p2_c3_c2 p2_9 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) -(28 rows) - -/*+IndexScan(p2 p2_expr)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_expr -LOG: available indexes for IndexScan(p2_c1): p2_c1_expr_idx -LOG: available indexes for IndexScan(p2_c2): p2_c2_expr_idx -LOG: available indexes for IndexScan(p2_c3): p2_c3_expr_idx -LOG: available indexes for IndexScan(p2_c4): p2_c4_expr_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_expr_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_expr_idx -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_expr_idx -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_expr_idx -LOG: pg_hint_plan: -used hint: -IndexScan(p2 p2_expr) -not used hint: -duplication hint: -error hint: + QUERY PLAN +------------------------------------------------------------------------------------------- + Nested Loop + Join Filter: (t4.id = t1.id) + -> Hash Join + Hash Cond: (t5.id = t4.id) + -> Seq Scan on t5 + -> Hash + -> Seq Scan on t4 + -> Materialize + -> Hash Join + Hash Cond: (t3.id = t1.id) + -> Seq Scan on t3 + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1, $2, ..., $1023])) +(17 rows) - QUERY PLAN ------------------------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1 p2_2 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c2 p2_3 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3 p2_4 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c4 p2_5 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) -(19 rows) - -/*+IndexScan(p2 p2_val_idx6)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_val_idx6 -LOG: available indexes for IndexScan(p2_c1): p2_c1_val_idx7 -LOG: available indexes for IndexScan(p2_c2): p2_c2_val_idx7 -LOG: available indexes for IndexScan(p2_c3): p2_c3_val_idx7 -LOG: available indexes for IndexScan(p2_c4): p2_c4_val_idx7 -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_val_idx7 -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_val_idx7 -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_val_idx7 -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_val_idx7 +/*+Leading((((t1 t2)t3)(t4 t5)))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_val_idx6) +Leading((((t1 t2) t3) (t4 t5))) not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------------------------ - Append - -> Seq Scan on p2 p2_1 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1 p2_2 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c2 p2_3 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3 p2_4 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c4 p2_5 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: ((val >= '50'::text) AND (val <= '51'::text) AND (ctid = '(1,1)'::tid)) -(19 rows) - -/*+IndexScan(p2 p2_val_idx p2_val_idx6)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -LOG: available indexes for IndexScan(p2): p2_val_idx6 p2_val_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_val_idx7 p2_c1_val_idx -LOG: available indexes for IndexScan(p2_c2): p2_c2_val_idx7 p2_c2_val_idx -LOG: available indexes for IndexScan(p2_c3): p2_c3_val_idx7 p2_c3_val_idx -LOG: available indexes for IndexScan(p2_c4): p2_c4_val_idx7 p2_c4_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_val_idx7 p2_c1_c1_val_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_val_idx7 p2_c1_c2_val_idx -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_val_idx7 p2_c3_c1_val_idx -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_val_idx7 p2_c3_c2_val_idx + QUERY PLAN +------------------------------------------------------------------------------- + Nested Loop + Join Filter: (t4.id = t1.id) + -> Hash Join + Hash Cond: (t1.id = t3.id) + -> Hash Join + Hash Cond: (t1.id = t2.id) + -> Seq Scan on t1 + -> Hash + -> Seq Scan on t2 + -> Hash + -> Seq Scan on t3 + -> Materialize + -> YB Batched Nested Loop Join + Join Filter: (t4.id = t5.id) + -> Seq Scan on t4 + -> Index Scan using t5_pkey on t5 + Index Cond: (id = ANY (ARRAY[t4.id, $1, $2, ..., $1023])) +(17 rows) + +/*+Leading((((t5 t4)t3)(t2 t1)))*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; LOG: pg_hint_plan: used hint: -IndexScan(p2 p2_val_idx p2_val_idx6) +Leading((((t5 t4) t3) (t2 t1))) not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------------------------- - Append - -> Index Scan using p2_val_idx on p2 p2_1 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_val_idx on p2_c1 p2_2 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c2_val_idx on p2_c2 p2_3 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c3_val_idx on p2_c3 p2_4 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c4_val_idx on p2_c4 p2_5 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c1_val_idx on p2_c1_c1 p2_6 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c1_c2_val_idx on p2_c1_c2 p2_7 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c3_c1_val_idx on p2_c3_c1 p2_8 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) - -> Index Scan using p2_c3_c2_val_idx on p2_c3_c2 p2_9 - Index Cond: ((val >= '50'::text) AND (val <= '51'::text)) - Filter: (ctid = '(1,1)'::tid) -(28 rows) + QUERY PLAN +------------------------------------------------------------------------------------- + Hash Join + Hash Cond: (t3.id = t1.id) + -> YB Batched Nested Loop Join + Join Filter: (t4.id = t3.id) + -> Hash Join + Hash Cond: (t5.id = t4.id) + -> Seq Scan on t5 + -> Hash + -> Seq Scan on t4 + -> Index Scan using t3_pkey on t3 + Index Cond: (id = ANY (ARRAY[t5.id, $1, $2, ..., $1023])) + -> Hash + -> YB Batched Nested Loop Join + Join Filter: (t1.id = t2.id) + -> Seq Scan on t2 + -> Index Scan using t1_pkey on t1 + Index Cond: (id = ANY (ARRAY[t2.id, $1025, $1026, ..., $2047])) +(17 rows) +-- YB_COMMENT +-- Inheritance not supporte by Yugabyte +-- inherite table test to specify the index's name +EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +ERROR: System column "ctid" is not supported yet +-- /*+IndexScan(p2 p2_pkey)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_id_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val_id_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- +-- 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)'; +-- /*+IndexScan(p2 p2_pkey)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_id2_val)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val2_id)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- +-- /*+IndexScan(p2 p2_pkey)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_c1_id_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey p2_c1_id_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_c1_id_val_idx no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- +-- /*+IndexScan(p2 p2_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_expr)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val_idx6)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val_idx p2_val_idx6)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- -- regular expression -- ordinary table EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7260,7 +3694,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN -------------------------------- Index Scan using t5_pkey on t5 Index Cond: (id = 1) @@ -7276,7 +3710,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------- Index Scan using t5_id3 on t5 Index Cond: (id = 1) @@ -7292,9 +3726,9 @@ IndexScanRegexp(t5 t5[^_].*) duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7308,9 +3742,9 @@ IndexScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7324,9 +3758,9 @@ IndexScan(t5 t5_id[0-9].*) duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7340,9 +3774,9 @@ not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------- - Index Only Scan using t5_pkey on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7356,7 +3790,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN ------------------------------------ Index Only Scan using t5_id3 on t5 Index Cond: (id = 1) @@ -7372,9 +3806,9 @@ IndexOnlyScanRegexp(t5 t5[^_].*) duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7388,9 +3822,9 @@ IndexOnlyScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7404,12 +3838,14 @@ IndexOnlyScan(t5 t5_id[0-9].*) duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) +-- YB_COMMENT +-- Yugabyte does not support bitmap scan /*+ BitmapScanRegexp(t5 t5_[^i].*)*/ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; LOG: available indexes for BitmapScanRegexp(t5): t5_val t5_pkey @@ -7420,13 +3856,11 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------- - Bitmap Heap Scan on t5 - Recheck Cond: (id = 1) - -> Bitmap Index Scan on t5_pkey - Index Cond: (id = 1) -(4 rows) + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 + Index Cond: (id = 1) +(2 rows) /*+ BitmapScanRegexp(t5 t5_id[0-9].*)*/ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; @@ -7438,13 +3872,11 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------ - Bitmap Heap Scan on t5 - Recheck Cond: (id = 1) - -> Bitmap Index Scan on t5_id3 - Index Cond: (id = 1) -(4 rows) + QUERY PLAN +--------------------------- + Seq Scan on t5 + Remote Filter: (id = 1) +(2 rows) /*+ BitmapScanRegexp(t5 t5[^_].*)*/ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; @@ -7456,9 +3888,9 @@ BitmapScanRegexp(t5 t5[^_].*) duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) @@ -7472,569 +3904,68 @@ BitmapScanRegexp(t5 ^.*t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa duplication hint: error hint: - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 Index Cond: (id = 1) (2 rows) /*+ BitmapScan(t5 t5_id[0-9].*)*/ -EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; -LOG: available indexes for BitmapScan(t5): -LOG: pg_hint_plan: -used hint: -not used hint: -BitmapScan(t5 t5_id[0-9].*) -duplication hint: -error hint: - - QUERY PLAN ---------------------------------------------------------------------------------------------- - Index Only Scan using t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa on t5 - Index Cond: (id = 1) -(2 rows) - --- Inheritance -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ IndexScanRegexp(p1 p1_.*[^0-9]$)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexScanRegexp(p1): p1_pkey -LOG: available indexes for IndexScanRegexp(p1_c1): p1_c1_pkey -LOG: available indexes for IndexScanRegexp(p1_c2): p1_c2_pkey -LOG: available indexes for IndexScanRegexp(p1_c3): p1_c3_pkey -LOG: available indexes for IndexScanRegexp(p1_c4): p1_c4_pkey -LOG: available indexes for IndexScanRegexp(p1_c1_c1): p1_c1_c1_pkey -LOG: available indexes for IndexScanRegexp(p1_c1_c2): p1_c1_c2_pkey -LOG: available indexes for IndexScanRegexp(p1_c3_c1): p1_c3_c1_pkey -LOG: available indexes for IndexScanRegexp(p1_c3_c2): p1_c3_c2_pkey -LOG: pg_hint_plan: -used hint: -IndexScanRegexp(p1 p1_.*[^0-9]$) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ IndexScanRegexp(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexScanRegexp(p1): p1_val2 -LOG: available indexes for IndexScanRegexp(p1_c1): p1_c1_val2 -LOG: available indexes for IndexScanRegexp(p1_c2): p1_c2_val2 -LOG: available indexes for IndexScanRegexp(p1_c3): p1_c3_val2 -LOG: available indexes for IndexScanRegexp(p1_c4): p1_c4_val2 -LOG: available indexes for IndexScanRegexp(p1_c1_c1): p1_c1_c1_val2 -LOG: available indexes for IndexScanRegexp(p1_c1_c2): p1_c1_c2_val2 -LOG: available indexes for IndexScanRegexp(p1_c3_c1): p1_c3_c1_val2 -LOG: available indexes for IndexScanRegexp(p1_c3_c2): p1_c3_c2_val2 -LOG: pg_hint_plan: -used hint: -IndexScanRegexp(p1 p1_.*val2.*) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------- - Append - -> Index Scan using p1_val2 on p1 p1_1 - Index Cond: (val = 1) - -> Index Scan using p1_c1_val2 on p1_c1 p1_2 - Index Cond: (val = 1) - -> Index Scan using p1_c2_val2 on p1_c2 p1_3 - Index Cond: (val = 1) - -> Index Scan using p1_c3_val2 on p1_c3 p1_4 - Index Cond: (val = 1) - -> Index Scan using p1_c4_val2 on p1_c4 p1_5 - Index Cond: (val = 1) - -> Index Scan using p1_c1_c1_val2 on p1_c1_c1 p1_6 - Index Cond: (val = 1) - -> Index Scan using p1_c1_c2_val2 on p1_c1_c2 p1_7 - Index Cond: (val = 1) - -> Index Scan using p1_c3_c1_val2 on p1_c3_c1 p1_8 - Index Cond: (val = 1) - -> Index Scan using p1_c3_c2_val2 on p1_c3_c2 p1_9 - Index Cond: (val = 1) -(19 rows) - -/*+ IndexScanRegexp(p1 p1[^_].*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexScanRegexp(p1): -LOG: available indexes for IndexScanRegexp(p1_c1): -LOG: available indexes for IndexScanRegexp(p1_c2): -LOG: available indexes for IndexScanRegexp(p1_c3): -LOG: available indexes for IndexScanRegexp(p1_c4): -LOG: available indexes for IndexScanRegexp(p1_c1_c1): -LOG: available indexes for IndexScanRegexp(p1_c1_c2): -LOG: available indexes for IndexScanRegexp(p1_c3_c1): -LOG: available indexes for IndexScanRegexp(p1_c3_c2): -LOG: pg_hint_plan: -used hint: -not used hint: -IndexScanRegexp(p1 p1[^_].*) -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ IndexScan(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexScan(p1): -LOG: available indexes for IndexScan(p1_c1): -LOG: available indexes for IndexScan(p1_c2): -LOG: available indexes for IndexScan(p1_c3): -LOG: available indexes for IndexScan(p1_c4): -LOG: available indexes for IndexScan(p1_c1_c1): -LOG: available indexes for IndexScan(p1_c1_c2): -LOG: available indexes for IndexScan(p1_c3_c1): -LOG: available indexes for IndexScan(p1_c3_c2): -LOG: pg_hint_plan: -used hint: -not used hint: -IndexScan(p1 p1_.*val2.*) -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ IndexOnlyScanRegexp(p1 p1_.*[^0-9]$)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexOnlyScanRegexp(p1): p1_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c1): p1_c1_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c2): p1_c2_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c3): p1_c3_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c4): p1_c4_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c1_c1): p1_c1_c1_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c1_c2): p1_c1_c2_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c1): p1_c3_c1_pkey -LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c2): p1_c3_c2_pkey -LOG: pg_hint_plan: -used hint: -IndexOnlyScanRegexp(p1 p1_.*[^0-9]$) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ IndexOnlyScanRegexp(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexOnlyScanRegexp(p1): p1_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c1): p1_c1_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c2): p1_c2_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c3): p1_c3_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c4): p1_c4_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c1_c1): p1_c1_c1_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c1_c2): p1_c1_c2_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c1): p1_c3_c1_val2 -LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c2): p1_c3_c2_val2 -LOG: pg_hint_plan: -used hint: -IndexOnlyScanRegexp(p1 p1_.*val2.*) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------------------- - Append - -> Index Only Scan using p1_val2 on p1 p1_1 - Index Cond: (val = 1) - -> Index Only Scan using p1_c1_val2 on p1_c1 p1_2 - Index Cond: (val = 1) - -> Index Only Scan using p1_c2_val2 on p1_c2 p1_3 - Index Cond: (val = 1) - -> Index Only Scan using p1_c3_val2 on p1_c3 p1_4 - Index Cond: (val = 1) - -> Index Only Scan using p1_c4_val2 on p1_c4 p1_5 - Index Cond: (val = 1) - -> Index Only Scan using p1_c1_c1_val2 on p1_c1_c1 p1_6 - Index Cond: (val = 1) - -> Index Only Scan using p1_c1_c2_val2 on p1_c1_c2 p1_7 - Index Cond: (val = 1) - -> Index Only Scan using p1_c3_c1_val2 on p1_c3_c1 p1_8 - Index Cond: (val = 1) - -> Index Only Scan using p1_c3_c2_val2 on p1_c3_c2 p1_9 - Index Cond: (val = 1) -(19 rows) - -/*+ IndexOnlyScanRegexp(p1 p1[^_].*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexOnlyScanRegexp(p1): -LOG: available indexes for IndexOnlyScanRegexp(p1_c1): -LOG: available indexes for IndexOnlyScanRegexp(p1_c2): -LOG: available indexes for IndexOnlyScanRegexp(p1_c3): -LOG: available indexes for IndexOnlyScanRegexp(p1_c4): -LOG: available indexes for IndexOnlyScanRegexp(p1_c1_c1): -LOG: available indexes for IndexOnlyScanRegexp(p1_c1_c2): -LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c1): -LOG: available indexes for IndexOnlyScanRegexp(p1_c3_c2): -LOG: pg_hint_plan: -used hint: -not used hint: -IndexOnlyScanRegexp(p1 p1[^_].*) -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ IndexOnlyScan(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for IndexOnlyScan(p1): -LOG: available indexes for IndexOnlyScan(p1_c1): -LOG: available indexes for IndexOnlyScan(p1_c2): -LOG: available indexes for IndexOnlyScan(p1_c3): -LOG: available indexes for IndexOnlyScan(p1_c4): -LOG: available indexes for IndexOnlyScan(p1_c1_c1): -LOG: available indexes for IndexOnlyScan(p1_c1_c2): -LOG: available indexes for IndexOnlyScan(p1_c3_c1): -LOG: available indexes for IndexOnlyScan(p1_c3_c2): -LOG: pg_hint_plan: -used hint: -not used hint: -IndexOnlyScan(p1 p1_.*val2.*) -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ BitmapScanRegexp(p1 p1_.*[^0-9]$)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for BitmapScanRegexp(p1): p1_pkey -LOG: available indexes for BitmapScanRegexp(p1_c1): p1_c1_pkey -LOG: available indexes for BitmapScanRegexp(p1_c2): p1_c2_pkey -LOG: available indexes for BitmapScanRegexp(p1_c3): p1_c3_pkey -LOG: available indexes for BitmapScanRegexp(p1_c4): p1_c4_pkey -LOG: available indexes for BitmapScanRegexp(p1_c1_c1): p1_c1_c1_pkey -LOG: available indexes for BitmapScanRegexp(p1_c1_c2): p1_c1_c2_pkey -LOG: available indexes for BitmapScanRegexp(p1_c3_c1): p1_c3_c1_pkey -LOG: available indexes for BitmapScanRegexp(p1_c3_c2): p1_c3_c2_pkey -LOG: pg_hint_plan: -used hint: -BitmapScanRegexp(p1 p1_.*[^0-9]$) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ BitmapScanRegexp(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for BitmapScanRegexp(p1): p1_val2 -LOG: available indexes for BitmapScanRegexp(p1_c1): p1_c1_val2 -LOG: available indexes for BitmapScanRegexp(p1_c2): p1_c2_val2 -LOG: available indexes for BitmapScanRegexp(p1_c3): p1_c3_val2 -LOG: available indexes for BitmapScanRegexp(p1_c4): p1_c4_val2 -LOG: available indexes for BitmapScanRegexp(p1_c1_c1): p1_c1_c1_val2 -LOG: available indexes for BitmapScanRegexp(p1_c1_c2): p1_c1_c2_val2 -LOG: available indexes for BitmapScanRegexp(p1_c3_c1): p1_c3_c1_val2 -LOG: available indexes for BitmapScanRegexp(p1_c3_c2): p1_c3_c2_val2 -LOG: pg_hint_plan: -used hint: -BitmapScanRegexp(p1 p1_.*val2.*) -not used hint: -duplication hint: -error hint: - - QUERY PLAN ------------------------------------------------- - Append - -> Bitmap Heap Scan on p1 p1_1 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c1 p1_2 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c1_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c2 p1_3 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c2_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c3 p1_4 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c3_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c4 p1_5 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c4_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c1_c1 p1_6 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c1_c1_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c1_c2 p1_7 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c1_c2_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c3_c1 p1_8 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c3_c1_val2 - Index Cond: (val = 1) - -> Bitmap Heap Scan on p1_c3_c2 p1_9 - Recheck Cond: (val = 1) - -> Bitmap Index Scan on p1_c3_c2_val2 - Index Cond: (val = 1) -(37 rows) - -/*+ BitmapScanRegexp(p1 p1[^_].*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for BitmapScanRegexp(p1): -LOG: available indexes for BitmapScanRegexp(p1_c1): -LOG: available indexes for BitmapScanRegexp(p1_c2): -LOG: available indexes for BitmapScanRegexp(p1_c3): -LOG: available indexes for BitmapScanRegexp(p1_c4): -LOG: available indexes for BitmapScanRegexp(p1_c1_c1): -LOG: available indexes for BitmapScanRegexp(p1_c1_c2): -LOG: available indexes for BitmapScanRegexp(p1_c3_c1): -LOG: available indexes for BitmapScanRegexp(p1_c3_c2): -LOG: pg_hint_plan: -used hint: -not used hint: -BitmapScanRegexp(p1 p1[^_].*) -duplication hint: -error hint: - - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) - -/*+ BitmapScan(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -LOG: available indexes for BitmapScan(p1): -LOG: available indexes for BitmapScan(p1_c1): -LOG: available indexes for BitmapScan(p1_c2): -LOG: available indexes for BitmapScan(p1_c3): -LOG: available indexes for BitmapScan(p1_c4): -LOG: available indexes for BitmapScan(p1_c1_c1): -LOG: available indexes for BitmapScan(p1_c1_c2): -LOG: available indexes for BitmapScan(p1_c3_c1): -LOG: available indexes for BitmapScan(p1_c3_c2): +EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; +LOG: available indexes for BitmapScan(t5): LOG: pg_hint_plan: used hint: not used hint: -BitmapScan(p1 p1_.*val2.*) +BitmapScan(t5 t5_id[0-9].*) duplication hint: error hint: - QUERY PLAN ---------------------------------- - Append - -> Seq Scan on p1 p1_1 - Filter: (val = 1) - -> Seq Scan on p1_c1 p1_2 - Filter: (val = 1) - -> Seq Scan on p1_c2 p1_3 - Filter: (val = 1) - -> Seq Scan on p1_c3 p1_4 - Filter: (val = 1) - -> Seq Scan on p1_c4 p1_5 - Filter: (val = 1) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val = 1) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val = 1) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val = 1) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val = 1) -(19 rows) + QUERY PLAN +-------------------------------- + Index Scan using t5_pkey on t5 + Index Cond: (id = 1) +(2 rows) +-- YB_COMMENT +-- Inheritance +EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; + QUERY PLAN +---------------------------- + Seq Scan on p1 + Remote Filter: (val = 1) +(2 rows) + +-- /*+ IndexScanRegexp(p1 p1_.*[^0-9]$)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexScanRegexp(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexScanRegexp(p1 p1[^_].*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexScan(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScanRegexp(p1 p1_.*[^0-9]$)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScanRegexp(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScanRegexp(p1 p1[^_].*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScan(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScanRegexp(p1 p1_.*[^0-9]$)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScanRegexp(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScanRegexp(p1 p1[^_].*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScan(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- -- search from hint table INSERT INTO hint_plan.hints (norm_query_string, application_name, hints) VALUES ('EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?;', '', 'SeqScan(t1)'); INSERT INTO hint_plan.hints (norm_query_string, application_name, hints) VALUES ('EXPLAIN (COSTS false) SELECT id FROM t1 WHERE t1.id = ?;', '', 'IndexScan(t1)'); INSERT INTO hint_plan.hints (norm_query_string, application_name, hints) VALUES ('EXPLAIN SELECT * FROM t1 WHERE t1.id = ?;', '', 'BitmapScan(t1)'); SELECT * FROM hint_plan.hints ORDER BY id; - id | norm_query_string | application_name | hints + id | norm_query_string | application_name | hints ----+----------------------------------------------------------+------------------+---------------- 1 | EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?; | | SeqScan(t1) 2 | EXPLAIN (COSTS false) SELECT id FROM t1 WHERE t1.id = ?; | | IndexScan(t1) @@ -8050,15 +3981,15 @@ not used hint: duplication hint: error hint: - QUERY PLAN --------------------- + QUERY PLAN +--------------------------- Seq Scan on t1 - Filter: (id = 1) + Remote Filter: (id = 1) (2 rows) SET pg_hint_plan.enable_hint_table = off; EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = 1; - QUERY PLAN + QUERY PLAN -------------------------------- Index Scan using t1_pkey on t1 Index Cond: (id = 1) @@ -8066,11 +3997,12 @@ EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = 1; TRUNCATE hint_plan.hints; VACUUM ANALYZE hint_plan.hints; +WARNING: VACUUM will be ignored -- plpgsql test EXPLAIN (COSTS false) SELECT id FROM t1 WHERE t1.id = 1; - QUERY PLAN -------------------------------------- - Index Only Scan using t1_pkey on t1 + QUERY PLAN +-------------------------------- + Index Scan using t1_pkey on t1 Index Cond: (id = 1) (2 rows) @@ -8093,9 +4025,9 @@ error hint: CONTEXT: SQL statement "SELECT /*+ SeqScan(t1) */ * FROM t1 LIMIT 1" PL/pgSQL function testfunc() line 5 at SQL statement - testfunc + testfunc ---------- - (1,1) + (854,54) (1 row) -- dynamic function @@ -8115,9 +4047,9 @@ error hint: CONTEXT: SQL statement "/*+ SeqScan(t1) */ SELECT * FROM t1" PL/pgSQL function testfunc() line 3 at EXECUTE - testfunc + testfunc ---------- - + (1 row) -- This should not use SeqScan(t1) @@ -8129,9 +4061,9 @@ not used hint: duplication hint: error hint: - id | val -----+----- - 1 | 1 + id | val +-----+----- + 854 | 54 (1 row) -- Perform @@ -8151,9 +4083,9 @@ error hint: CONTEXT: SQL statement "SELECT 1, /*+ SeqScan(t1) */ * from t1" PL/pgSQL function testfunc() line 3 at PERFORM - testfunc + testfunc ---------- - + (1 row) -- FOR loop @@ -8180,9 +4112,9 @@ error hint: CONTEXT: SQL statement "SELECT /*+ SeqScan(t1) */ v FROM t1 ORDER BY id" PL/pgSQL function testfunc() line 7 at FOR over SELECT rows - testfunc + testfunc ---------- - + (1 row) -- Dynamic FOR loop @@ -8210,7 +4142,7 @@ error hint: CONTEXT: SQL statement "SELECT /*+ SeqScan(t1) */ val FROM t1 ORDER BY id" PL/pgSQL function testfunc() line 8 at FOR over EXECUTE statement - testfunc + testfunc ---------- 0 (1 row) @@ -8239,7 +4171,7 @@ error hint: CONTEXT: SQL statement "SELECT /*+ SeqScan(t1) */ * FROM t1 ORDER BY id" PL/pgSQL function testfunc() line 7 at FOR over cursor - testfunc + testfunc ---------- 495000 (1 row) @@ -8261,7 +4193,7 @@ error hint: CONTEXT: SQL statement "SELECT /*+ SeqScan(t1) */ * FROM t1 ORDER BY id" PL/pgSQL function testfunc() line 3 at RETURN QUERY - id | val + id | val ----+----- 1 | 1 (1 row) @@ -8288,9 +4220,9 @@ not used hint: duplication hint: error hint: - id | val -----+----- - 1 | 1 + id | val +-----+----- + 854 | 54 (1 row) DROP FUNCTION testfunc(); @@ -8307,837 +4239,181 @@ BEGIN END LOOP; END; $$ LANGUAGE plpgsql; +-- YB_COMMENT +-- pg_stat_user_tables not supportd by YB -- Dynamic query in pl/pgsql -CREATE OR REPLACE FUNCTION dynsql1(x int) RETURNS int AS $$ -DECLARE c int; -BEGIN - EXECUTE '/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1' - INTO c USING x; - RETURN c; -END; -$$ VOLATILE LANGUAGE plpgsql; -vacuum analyze t1; -SET pg_hint_plan.enable_hint = false; -SELECT pg_sleep(1); - pg_sleep ----------- - -(1 row) - -SELECT reset_stats_and_wait(); - reset_stats_and_wait ----------------------- - -(1 row) - -SELECT dynsql1(9000); - dynsql1 ---------- - 8999 -(1 row) - -SELECT pg_sleep(1); - pg_sleep ----------- - -(1 row) - -SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; - relname | seq_scan | idx_scan ----------+----------+---------- - t1 | t | f -(1 row) - -SET pg_hint_plan.enable_hint = true; -SELECT reset_stats_and_wait(); - reset_stats_and_wait ----------------------- - -(1 row) - -SELECT dynsql1(9000); -LOG: pg_hint_plan: -used hint: -IndexScan(t1) -not used hint: -duplication hint: -error hint: - -CONTEXT: SQL statement "/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1" -PL/pgSQL function dynsql1(integer) line 4 at EXECUTE - dynsql1 ---------- - 8999 -(1 row) - -SELECT pg_sleep(1); - pg_sleep ----------- - -(1 row) - -SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; - relname | seq_scan | idx_scan ----------+----------+---------- - t1 | f | t -(1 row) - --- Looped dynamic query in pl/pgsql -CREATE OR REPLACE FUNCTION dynsql2(x int, OUT r int) AS $$ -DECLARE - c text; - s int; -BEGIN - r := 0; - FOR c IN SELECT f.f FROM (VALUES ('p1_c1'), ('p1_c2')) f(f) LOOP - FOR s IN EXECUTE '/*+ IndexScan(' || c || ' ' || c || '_pkey) */ SELECT sum(val) FROM ' || c || ' WHERE id < ' || x LOOP - r := r + s; - END LOOP; - END LOOP; -END; -$$ VOLATILE LANGUAGE plpgsql; -SET pg_hint_plan.enable_hint = false; -SELECT reset_stats_and_wait(); - reset_stats_and_wait ----------------------- - -(1 row) - -SELECT dynsql2(9000); - dynsql2 ---------- - 9900 -(1 row) - -SELECT pg_sleep(1); - pg_sleep ----------- - -(1 row) - --- one of the index scans happened while planning. -SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); - relname | seq_scan | idx_scan ----------+----------+---------- - p1_c1 | 1 | 0 - p1_c2 | 1 | 1 -(2 rows) - -SET pg_hint_plan.enable_hint = true; -SELECT reset_stats_and_wait(); - reset_stats_and_wait ----------------------- - -(1 row) - -SELECT dynsql2(9000); -LOG: available indexes for IndexScan(p1_c1): p1_c1_pkey -CONTEXT: SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000" -PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement -LOG: available indexes for IndexScan(p1_c1_c1): p1_c1_c1_pkey -CONTEXT: SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000" -PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement -LOG: available indexes for IndexScan(p1_c1_c2): p1_c1_c2_pkey -CONTEXT: SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000" -PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement -LOG: pg_hint_plan: -used hint: -IndexScan(p1_c1 p1_c1_pkey) -not used hint: -duplication hint: -error hint: - -CONTEXT: SQL statement "/*+ IndexScan(p1_c1 p1_c1_pkey) */ SELECT sum(val) FROM p1_c1 WHERE id < 9000" -PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement -LOG: available indexes for IndexScan(p1_c2): p1_c2_pkey -CONTEXT: SQL statement "/*+ IndexScan(p1_c2 p1_c2_pkey) */ SELECT sum(val) FROM p1_c2 WHERE id < 9000" -PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement -LOG: pg_hint_plan: -used hint: -IndexScan(p1_c2 p1_c2_pkey) -not used hint: -duplication hint: -error hint: - -CONTEXT: SQL statement "/*+ IndexScan(p1_c2 p1_c2_pkey) */ SELECT sum(val) FROM p1_c2 WHERE id < 9000" -PL/pgSQL function dynsql2(integer) line 8 at FOR over EXECUTE statement - dynsql2 ---------- - 9900 -(1 row) - -SELECT pg_sleep(1); - pg_sleep ----------- - -(1 row) - --- the index scan happened while planning. -SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); - relname | seq_scan | idx_scan ----------+----------+---------- - p1_c1 | 0 | 1 - p1_c2 | 0 | 2 -(2 rows) - --- Subqueries on inheritance tables under UNION -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION ALL -SELECT val::int FROM p2 WHERE id < 1000; - QUERY PLAN ---------------------------------------------- - Append - -> Append - -> Seq Scan on p1 p1_1 - Filter: (val < 1000) - -> Seq Scan on p1_c1 p1_2 - Filter: (val < 1000) - -> Seq Scan on p1_c2 p1_3 - Filter: (val < 1000) - -> Seq Scan on p1_c3 p1_4 - Filter: (val < 1000) - -> Seq Scan on p1_c4 p1_5 - Filter: (val < 1000) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val < 1000) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val < 1000) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val < 1000) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val < 1000) - -> Result - -> Append - -> Seq Scan on p2 p2_1 - Filter: (id < 1000) - -> Seq Scan on p2_c1 p2_2 - Filter: (id < 1000) - -> Seq Scan on p2_c2 p2_3 - Filter: (id < 1000) - -> Seq Scan on p2_c3 p2_4 - Filter: (id < 1000) - -> Seq Scan on p2_c4 p2_5 - Filter: (id < 1000) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: (id < 1000) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: (id < 1000) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: (id < 1000) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: (id < 1000) -(40 rows) - -/*+ IndexScan(p1 p1_val2) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION ALL -SELECT val::int FROM p2 WHERE id < 1000; -LOG: available indexes for IndexScan(p1): p1_val3 p1_val2 p1_val1 -LOG: available indexes for IndexScan(p1_c1): p1_c1_val3 p1_c1_val2 p1_c1_val1 -LOG: available indexes for IndexScan(p1_c2): p1_c2_val3 p1_c2_val2 p1_c2_val1 -LOG: available indexes for IndexScan(p1_c3): p1_c3_val3 p1_c3_val2 p1_c3_val1 -LOG: available indexes for IndexScan(p1_c4): p1_c4_val3 p1_c4_val2 p1_c4_val1 -LOG: available indexes for IndexScan(p1_c1_c1): p1_c1_c1_val3 p1_c1_c1_val2 p1_c1_c1_val1 -LOG: available indexes for IndexScan(p1_c1_c2): p1_c1_c2_val3 p1_c1_c2_val2 p1_c1_c2_val1 -LOG: available indexes for IndexScan(p1_c3_c1): p1_c3_c1_val3 p1_c3_c1_val2 p1_c3_c1_val1 -LOG: available indexes for IndexScan(p1_c3_c2): p1_c3_c2_val3 p1_c3_c2_val2 p1_c3_c2_val1 -LOG: pg_hint_plan: -used hint: -IndexScan(p1 p1_val2) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------- - Append - -> Append - -> Index Scan using p1_val3 on p1 p1_1 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_val3 on p1_c1 p1_2 - Index Cond: (val < 1000) - -> Index Scan using p1_c2_val3 on p1_c2 p1_3 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_val3 on p1_c3 p1_4 - Index Cond: (val < 1000) - -> Index Scan using p1_c4_val3 on p1_c4 p1_5 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_c1_val3 on p1_c1_c1 p1_6 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_c2_val3 on p1_c1_c2 p1_7 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_c1_val3 on p1_c3_c1 p1_8 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_c2_val3 on p1_c3_c2 p1_9 - Index Cond: (val < 1000) - -> Result - -> Append - -> Seq Scan on p2 p2_1 - Filter: (id < 1000) - -> Seq Scan on p2_c1 p2_2 - Filter: (id < 1000) - -> Seq Scan on p2_c2 p2_3 - Filter: (id < 1000) - -> Seq Scan on p2_c3 p2_4 - Filter: (id < 1000) - -> Seq Scan on p2_c4 p2_5 - Filter: (id < 1000) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: (id < 1000) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: (id < 1000) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: (id < 1000) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: (id < 1000) -(40 rows) - -/*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION ALL -SELECT val::int FROM p2 WHERE id < 1000; -LOG: available indexes for IndexScan(p1): p1_val3 p1_val2 p1_val1 -LOG: available indexes for IndexScan(p1_c1): p1_c1_val3 p1_c1_val2 p1_c1_val1 -LOG: available indexes for IndexScan(p1_c2): p1_c2_val3 p1_c2_val2 p1_c2_val1 -LOG: available indexes for IndexScan(p1_c3): p1_c3_val3 p1_c3_val2 p1_c3_val1 -LOG: available indexes for IndexScan(p1_c4): p1_c4_val3 p1_c4_val2 p1_c4_val1 -LOG: available indexes for IndexScan(p1_c1_c1): p1_c1_c1_val3 p1_c1_c1_val2 p1_c1_c1_val1 -LOG: available indexes for IndexScan(p1_c1_c2): p1_c1_c2_val3 p1_c1_c2_val2 p1_c1_c2_val1 -LOG: available indexes for IndexScan(p1_c3_c1): p1_c3_c1_val3 p1_c3_c1_val2 p1_c3_c1_val1 -LOG: available indexes for IndexScan(p1_c3_c2): p1_c3_c2_val3 p1_c3_c2_val2 p1_c3_c2_val1 -LOG: available indexes for IndexScan(p2): p2_id_val_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c2): p2_c2_id_val_idx -LOG: available indexes for IndexScan(p2_c3): p2_c3_id_val_idx -LOG: available indexes for IndexScan(p2_c4): p2_c4_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx -LOG: pg_hint_plan: -used hint: -IndexScan(p1 p1_val2) -IndexScan(p2 p2_id_val_idx) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------------------- - Append - -> Append - -> Index Scan using p1_val3 on p1 p1_1 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_val3 on p1_c1 p1_2 - Index Cond: (val < 1000) - -> Index Scan using p1_c2_val3 on p1_c2 p1_3 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_val3 on p1_c3 p1_4 - Index Cond: (val < 1000) - -> Index Scan using p1_c4_val3 on p1_c4 p1_5 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_c1_val3 on p1_c1_c1 p1_6 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_c2_val3 on p1_c1_c2 p1_7 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_c1_val3 on p1_c3_c1 p1_8 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_c2_val3 on p1_c3_c2 p1_9 - Index Cond: (val < 1000) - -> Result - -> Append - -> Index Scan using p2_id_val_idx on p2 p2_1 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: (id < 1000) - -> Index Scan using p2_c2_id_val_idx on p2_c2 p2_3 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_id_val_idx on p2_c3 p2_4 - Index Cond: (id < 1000) - -> Index Scan using p2_c4_id_val_idx on p2_c4 p2_5 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_6 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_7 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_c1_id_val_idx on p2_c3_c1 p2_8 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_c2_id_val_idx on p2_c3_c2 p2_9 - Index Cond: (id < 1000) -(40 rows) - --- union all case -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION -SELECT val::int FROM p2 WHERE id < 1000; - QUERY PLAN ---------------------------------------------------- - HashAggregate - Group Key: p1.val - -> Append - -> Append - -> Seq Scan on p1 p1_1 - Filter: (val < 1000) - -> Seq Scan on p1_c1 p1_2 - Filter: (val < 1000) - -> Seq Scan on p1_c2 p1_3 - Filter: (val < 1000) - -> Seq Scan on p1_c3 p1_4 - Filter: (val < 1000) - -> Seq Scan on p1_c4 p1_5 - Filter: (val < 1000) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val < 1000) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val < 1000) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val < 1000) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val < 1000) - -> Result - -> Append - -> Seq Scan on p2 p2_1 - Filter: (id < 1000) - -> Seq Scan on p2_c1 p2_2 - Filter: (id < 1000) - -> Seq Scan on p2_c2 p2_3 - Filter: (id < 1000) - -> Seq Scan on p2_c3 p2_4 - Filter: (id < 1000) - -> Seq Scan on p2_c4 p2_5 - Filter: (id < 1000) - -> Seq Scan on p2_c1_c1 p2_6 - Filter: (id < 1000) - -> Seq Scan on p2_c1_c2 p2_7 - Filter: (id < 1000) - -> Seq Scan on p2_c3_c1 p2_8 - Filter: (id < 1000) - -> Seq Scan on p2_c3_c2 p2_9 - Filter: (id < 1000) -(42 rows) - -/*+ IndexScan(p2 p2_id_val_idx) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION -SELECT val::int FROM p2 WHERE id < 1000; -LOG: available indexes for IndexScan(p2): p2_id_val_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c2): p2_c2_id_val_idx -LOG: available indexes for IndexScan(p2_c3): p2_c3_id_val_idx -LOG: available indexes for IndexScan(p2_c4): p2_c4_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx -LOG: pg_hint_plan: -used hint: -IndexScan(p2 p2_id_val_idx) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------------------------- - HashAggregate - Group Key: p1.val - -> Append - -> Append - -> Seq Scan on p1 p1_1 - Filter: (val < 1000) - -> Seq Scan on p1_c1 p1_2 - Filter: (val < 1000) - -> Seq Scan on p1_c2 p1_3 - Filter: (val < 1000) - -> Seq Scan on p1_c3 p1_4 - Filter: (val < 1000) - -> Seq Scan on p1_c4 p1_5 - Filter: (val < 1000) - -> Seq Scan on p1_c1_c1 p1_6 - Filter: (val < 1000) - -> Seq Scan on p1_c1_c2 p1_7 - Filter: (val < 1000) - -> Seq Scan on p1_c3_c1 p1_8 - Filter: (val < 1000) - -> Seq Scan on p1_c3_c2 p1_9 - Filter: (val < 1000) - -> Result - -> Append - -> Index Scan using p2_id_val_idx on p2 p2_1 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: (id < 1000) - -> Index Scan using p2_c2_id_val_idx on p2_c2 p2_3 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_id_val_idx on p2_c3 p2_4 - Index Cond: (id < 1000) - -> Index Scan using p2_c4_id_val_idx on p2_c4 p2_5 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_6 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_7 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_c1_id_val_idx on p2_c3_c1 p2_8 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_c2_id_val_idx on p2_c3_c2 p2_9 - Index Cond: (id < 1000) -(42 rows) - -/*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION -SELECT val::int FROM p2 WHERE id < 1000; -LOG: available indexes for IndexScan(p1): p1_val3 p1_val2 p1_val1 -LOG: available indexes for IndexScan(p1_c1): p1_c1_val3 p1_c1_val2 p1_c1_val1 -LOG: available indexes for IndexScan(p1_c2): p1_c2_val3 p1_c2_val2 p1_c2_val1 -LOG: available indexes for IndexScan(p1_c3): p1_c3_val3 p1_c3_val2 p1_c3_val1 -LOG: available indexes for IndexScan(p1_c4): p1_c4_val3 p1_c4_val2 p1_c4_val1 -LOG: available indexes for IndexScan(p1_c1_c1): p1_c1_c1_val3 p1_c1_c1_val2 p1_c1_c1_val1 -LOG: available indexes for IndexScan(p1_c1_c2): p1_c1_c2_val3 p1_c1_c2_val2 p1_c1_c2_val1 -LOG: available indexes for IndexScan(p1_c3_c1): p1_c3_c1_val3 p1_c3_c1_val2 p1_c3_c1_val1 -LOG: available indexes for IndexScan(p1_c3_c2): p1_c3_c2_val3 p1_c3_c2_val2 p1_c3_c2_val1 -LOG: available indexes for IndexScan(p2): p2_id_val_idx -LOG: available indexes for IndexScan(p2_c1): p2_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c2): p2_c2_id_val_idx -LOG: available indexes for IndexScan(p2_c3): p2_c3_id_val_idx -LOG: available indexes for IndexScan(p2_c4): p2_c4_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c1): p2_c1_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c1_c2): p2_c1_c2_id_val_idx -LOG: available indexes for IndexScan(p2_c3_c1): p2_c3_c1_id_val_idx -LOG: available indexes for IndexScan(p2_c3_c2): p2_c3_c2_id_val_idx -LOG: pg_hint_plan: -used hint: -IndexScan(p1 p1_val2) -IndexScan(p2 p2_id_val_idx) -not used hint: -duplication hint: -error hint: - - QUERY PLAN -------------------------------------------------------------------------------- - HashAggregate - Group Key: p1.val - -> Append - -> Append - -> Index Scan using p1_val3 on p1 p1_1 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_val3 on p1_c1 p1_2 - Index Cond: (val < 1000) - -> Index Scan using p1_c2_val3 on p1_c2 p1_3 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_val3 on p1_c3 p1_4 - Index Cond: (val < 1000) - -> Index Scan using p1_c4_val3 on p1_c4 p1_5 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_c1_val3 on p1_c1_c1 p1_6 - Index Cond: (val < 1000) - -> Index Scan using p1_c1_c2_val3 on p1_c1_c2 p1_7 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_c1_val3 on p1_c3_c1 p1_8 - Index Cond: (val < 1000) - -> Index Scan using p1_c3_c2_val3 on p1_c3_c2 p1_9 - Index Cond: (val < 1000) - -> Result - -> Append - -> Index Scan using p2_id_val_idx on p2 p2_1 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_id_val_idx on p2_c1 p2_2 - Index Cond: (id < 1000) - -> Index Scan using p2_c2_id_val_idx on p2_c2 p2_3 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_id_val_idx on p2_c3 p2_4 - Index Cond: (id < 1000) - -> Index Scan using p2_c4_id_val_idx on p2_c4 p2_5 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_c1_id_val_idx on p2_c1_c1 p2_6 - Index Cond: (id < 1000) - -> Index Scan using p2_c1_c2_id_val_idx on p2_c1_c2 p2_7 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_c1_id_val_idx on p2_c3_c1 p2_8 - Index Cond: (id < 1000) - -> Index Scan using p2_c3_c2_id_val_idx on p2_c3_c2 p2_9 - Index Cond: (id < 1000) -(42 rows) - +-- CREATE OR REPLACE FUNCTION dynsql1(x int) RETURNS int AS $$ +-- DECLARE c int; +-- BEGIN +-- EXECUTE '/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1' +-- INTO c USING x; +-- RETURN c; +-- END; +-- $$ VOLATILE LANGUAGE plpgsql; +-- vacuum analyze t1; +-- SET pg_hint_plan.enable_hint = false; +-- SELECT pg_sleep(1); +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql1(9000); +-- SELECT pg_sleep(1); +-- SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; +-- SET pg_hint_plan.enable_hint = true; +-- SELECT pg_sleep(1); +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql1(9000); +-- SELECT pg_sleep(1); +-- SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; +-- +-- Dependent on inheritance +-- -- Looped dynamic query in pl/pgsql +-- CREATE OR REPLACE FUNCTION dynsql2(x int, OUT r int) AS $$ +-- DECLARE +-- c text; +-- s int; +-- BEGIN +-- r := 0; +-- FOR c IN SELECT f.f FROM (VALUES ('p1_c1'), ('p1_c2')) f(f) LOOP +-- FOR s IN EXECUTE '/*+ IndexScan(' || c || ' ' || c || '_pkey) */ SELECT sum(val) FROM ' || c || ' WHERE id < ' || x LOOP +-- r := r + s; +-- END LOOP; +-- END LOOP; +-- END; +-- $$ VOLATILE LANGUAGE plpgsql; +-- SET pg_hint_plan.enable_hint = false; +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql2(9000); +-- SELECT pg_sleep(1); +-- -- one of the index scans happened while planning. +-- SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); +-- SET pg_hint_plan.enable_hint = true; +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql2(9000); +-- SELECT pg_sleep(1); +-- -- the index scan happened while planning. +-- SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); +-- +-- -- Subqueries on inheritance tables under UNION +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION ALL +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p1 p1_val2) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION ALL +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION ALL +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- -- union all case +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p2 p2_id_val_idx) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION +-- SELECT val::int FROM p2 WHERE id < 1000; +-- -- -- Rows hint tests -- -- Explain result includes "Planning time" if COSTS is enabled, but -- this test needs it enabled for get rows count. So do tests via psql -- and grep -v the mutable line. --- Parse error check -/*+ Rows() */ SELECT 1; -INFO: pg_hint_plan: hint syntax error at or near " " -DETAIL: Rows hint needs at least one relation followed by one correction term. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Rows() - - ?column? ----------- - 1 -(1 row) - -/*+ Rows(x) */ SELECT 1; -INFO: pg_hint_plan: hint syntax error at or near " " -DETAIL: Rows hint needs at least one relation followed by one correction term. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Rows() - - ?column? ----------- - 1 -(1 row) - --- value types -\o results/pg_hint_plan.tmpout -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=1000 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 #99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 #99) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=99 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 +99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 +99) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=1099 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 -99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 -99) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=901 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 *99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 *99) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=99000 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 *0.01) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 *0.01) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=10 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 #aa) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR -INFO: pg_hint_plan: hint syntax error at or near "aa" -DETAIL: Rows hint requires valid number as rows estimation. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Rows(t1 t2 #aa) - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=1000 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 /99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR -INFO: pg_hint_plan: hint syntax error at or near "/99" -DETAIL: Unrecognized rows value type notation. -LOG: pg_hint_plan: -used hint: -not used hint: -duplication hint: -error hint: -Rows(t1 t2 /99) - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=1000 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - --- round up to 1 -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 -99999) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -WARNING: Force estimate to be at least one row, to avoid possible divide-by-zero when interpolating costs : Rows(t1 t2 -99999) -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 -99999) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=1 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - --- complex join tree -\o results/pg_hint_plan.tmpout -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=10 width=xxx) - Merge Cond: (t1.id = t3.id) - -> Merge Join (cost=xxx..xxx rows=1000 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -> Sort (cost=xxx..xxx rows=100 width=xxx) - Sort Key: t3.id - -> Seq Scan on t3 (cost=xxx..xxx rows=100 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 #22) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t2 #22) -not used hint: -duplication hint: -error hint: - -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=1 width=xxx) - Merge Cond: (t1.id = t3.id) - -> Merge Join (cost=xxx..xxx rows=22 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -> Sort (cost=xxx..xxx rows=100 width=xxx) - Sort Key: t3.id - -> Seq Scan on t3 (cost=xxx..xxx rows=100 width=xxx) - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t3 *10) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); -LOG: pg_hint_plan: -used hint: -Rows(t1 t3 *10) -not used hint: -duplication hint: -error hint: - -\o -set max_parallel_workers_per_gather to DEFAULT; -\! sql/maskout.sh results/pg_hint_plan.tmpout - QUERY PLAN ----------------- - Merge Join (cost=xxx..xxx rows=100 width=xxx) - Merge Cond: (t1.id = t3.id) - -> Merge Join (cost=xxx..xxx rows=1000 width=xxx) - Merge Cond: (t1.id = t2.id) - -> Index Scan using t1_pkey on t1 (cost=xxx..xxx rows=10000 width=xxx) - -> Index Scan using t2_pkey on t2 (cost=xxx..xxx rows=1000 width=xxx) - -> Sort (cost=xxx..xxx rows=100 width=xxx) - Sort Key: t3.id - -> Seq Scan on t3 (cost=xxx..xxx rows=100 width=xxx) - -\! rm results/pg_hint_plan.tmpout +-- +-- -- Parse error check +-- /*+ Rows() */ SELECT 1; +-- /*+ Rows(x) */ SELECT 1; +-- +-- -- value types +-- \o results/pg_hint_plan.tmpout +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 #99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 +99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 -99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 *99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 *0.01) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 #aa) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 /99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- -- round up to 1 +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 -99999) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- -- complex join tree +-- \o results/pg_hint_plan.tmpout +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 #22) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t3 *10) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); +-- \o +-- set max_parallel_workers_per_gather to DEFAULT; +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- \! rm results/pg_hint_plan.tmpout +-- -- hint error level set client_min_messages to 'DEBUG1'; /*+ SeqScan( */ SELECT 1; INFO: pg_hint_plan: hint syntax error at or near "" DETAIL: Closing parenthesis is necessary. - ?column? + ?column? ---------- 1 (1 row) @@ -9150,7 +4426,7 @@ not used hint: duplication hint: error hint: - id | val + id | val ----+----- (0 rows) @@ -9166,7 +4442,7 @@ not used hint: duplication hint: error hint: - id | val + id | val ----+----- (0 rows) @@ -9175,7 +4451,7 @@ 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? + ?column? ---------- 1 (1 row) @@ -9188,7 +4464,7 @@ not used hint: duplication hint: error hint: - id | val + id | val ----+----- (0 rows) @@ -9208,18 +4484,18 @@ not used hint: duplication hint: error hint: - QUERY PLAN -------------------------------------------------- - Nested Loop + QUERY PLAN +------------------------------------------------------------------- + YB Batched Nested Loop Join + Join Filter: (t1.id = t3.id) -> Merge Join - Merge Cond: (t2.id = t1.id) - -> Index Scan using t2_pkey on t2 + Merge Cond: (t1.id = t2.id) -> Sort Sort Key: t1.id - -> Gather - Workers Planned: 8 - -> Parallel Seq Scan on t1 + -> Seq Scan on t1 + -> Sort + Sort Key: t2.id + -> Seq Scan on t2 -> Index Scan using t3_pkey on t3 - Index Cond: (id = t1.id) -(11 rows) - + Index Cond: (id = ANY (ARRAY[t1.id, $1, $2, ..., $1023])) +(12 rows) diff --git a/expected/plpgsql.out b/expected/plpgsql.out index 0d44b6475177..c9e4027ca2e0 100644 --- a/expected/plpgsql.out +++ b/expected/plpgsql.out @@ -5,15 +5,19 @@ SET search_path TO public; SET client_min_messages TO log; \set SHOW_CONTEXT always LOAD 'pg_hint_plan'; +ERROR: LOAD not supported yet +LINE 1: LOAD 'pg_hint_plan'; + ^ +HINT: Please report the issue on https://github.com/YugaByte/yugabyte-db/issues SET pg_hint_plan.debug_print TO on; SELECT setting <> 'off' FROM pg_settings WHERE name = 'compute_query_id'; - ?column? + ?column? ---------- t (1 row) SHOW pg_hint_plan.enable_hint_table; - pg_hint_plan.enable_hint_table + pg_hint_plan.enable_hint_table -------------------------------- off (1 row) @@ -39,7 +43,7 @@ $$; -- when expected. begin; select set_config('compute_query_id','off', true); - set_config + set_config ------------ off (1 row) @@ -47,7 +51,7 @@ select set_config('compute_query_id','off', true); -- Show plan without hints explain (costs false) with test as (select 'z' val) select t1.val from test t1, test t2 where t1.val = t2.val; - QUERY PLAN + QUERY PLAN ---------------------------------- Nested Loop Join Filter: (t1.val = t2.val) @@ -68,9 +72,9 @@ NOTICE: Execution of test_hint_exception at level 2 CONTEXT: PL/pgSQL function test_hint_exception(integer) line 4 at RAISE SQL statement "select test_hint_exception(1)" PL/pgSQL function test_hint_exception(integer) line 10 at EXECUTE - test_hint_exception + test_hint_exception --------------------- - + (1 row) -- Show plan with hint, stored as an internal state of plpgsql_recurse_level. @@ -83,7 +87,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN --------------------------------- Merge Join Merge Cond: (t1.val = t2.val) @@ -100,7 +104,7 @@ error hint: -- This query should have the same plan as the first one, without hints. explain (costs false) with test as (select 'y' val) select t1.val from test t1, test t2 where t1.val = t2.val; - QUERY PLAN + QUERY PLAN ---------------------------------- Nested Loop Join Filter: (t1.val = t2.val) @@ -114,9 +118,9 @@ explain (costs false) with test as (select 'y' val) select test_hint_exception(1); NOTICE: Execution of test_hint_exception at level 2 CONTEXT: PL/pgSQL function test_hint_exception(integer) line 4 at RAISE - test_hint_exception + test_hint_exception --------------------- - + (1 row) -- Show plan with hint. @@ -129,7 +133,7 @@ not used hint: duplication hint: error hint: - QUERY PLAN + QUERY PLAN --------------------------------- Merge Join Merge Cond: (t1.val = t2.val) @@ -146,7 +150,7 @@ error hint: -- This query should have no hints. explain (costs false) with test as (select 'y' val) select t1.val from test t1, test t2 where t1.val = t2.val; - QUERY PLAN + QUERY PLAN ---------------------------------- Nested Loop Join Filter: (t1.val = t2.val) @@ -160,7 +164,7 @@ rollback; -- Still no hints used here. explain (costs false) with test as (select 'y' val) select t1.val from test t1, test t2 where t1.val = t2.val; - QUERY PLAN + QUERY PLAN ---------------------------------- Nested Loop Join Filter: (t1.val = t2.val) @@ -407,10 +411,10 @@ PL/pgSQL function test_hint_queries(integer,integer) line 21 at EXECUTE SQL statement "select test_hint_queries(3, 0)" PL/pgSQL function test_hint_transaction() line 5 at EXECUTE table test_hint_tab; - a + a --- - 0 2 + 0 (2 rows) drop procedure test_hint_transaction; diff --git a/pg_hint_plan--1.3.7.sql b/pg_hint_plan--1.3.7.sql new file mode 100644 index 000000000000..bda34623932f --- /dev/null +++ b/pg_hint_plan--1.3.7.sql @@ -0,0 +1,22 @@ +/* pg_hint_plan/pg_hint_plan--1.3.7.sql */ + +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION pg_hint_plan" to load this file. \quit + +CREATE TABLE hint_plan.hints ( + id serial NOT NULL, + norm_query_string text NOT NULL, + application_name text NOT NULL, + hints text NOT NULL, + PRIMARY KEY (id) +); +CREATE UNIQUE INDEX hints_norm_and_app ON hint_plan.hints ( + norm_query_string, + application_name +); + +SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints',''); +SELECT pg_catalog.pg_extension_config_dump('hint_plan.hints_id_seq',''); + +GRANT SELECT ON hint_plan.hints TO PUBLIC; +GRANT USAGE ON SCHEMA hint_plan TO PUBLIC; diff --git a/pg_hint_plan.c b/pg_hint_plan.c index e77fd6ecd66c..0440bd491659 100644 --- a/pg_hint_plan.c +++ b/pg_hint_plan.c @@ -86,9 +86,11 @@ PG_MODULE_MAGIC; #define HINT_PARALLEL "Parallel" #define HINT_NESTLOOP "NestLoop" +#define HINT_BATCHEDNL "YbBatchedNL" #define HINT_MERGEJOIN "MergeJoin" #define HINT_HASHJOIN "HashJoin" #define HINT_NONESTLOOP "NoNestLoop" +#define HINT_NOBATCHEDNL "NoYbBatchedNL" #define HINT_NOMERGEJOIN "NoMergeJoin" #define HINT_NOHASHJOIN "NoHashJoin" #define HINT_LEADING "Leading" @@ -125,13 +127,15 @@ enum ENABLE_NESTLOOP = 0x01, ENABLE_MERGEJOIN = 0x02, ENABLE_HASHJOIN = 0x04, - ENABLE_MEMOIZE = 0x08 + ENABLE_MEMOIZE = 0x08, + ENABLE_BATCHEDNL = 0x10 } JOIN_TYPE_BITS; #define ENABLE_ALL_SCAN (ENABLE_SEQSCAN | ENABLE_INDEXSCAN | \ ENABLE_BITMAPSCAN | ENABLE_TIDSCAN | \ ENABLE_INDEXONLYSCAN) -#define ENABLE_ALL_JOIN (ENABLE_NESTLOOP | ENABLE_MERGEJOIN | ENABLE_HASHJOIN) +#define ENABLE_ALL_JOIN (ENABLE_NESTLOOP | ENABLE_MERGEJOIN | \ + ENABLE_HASHJOIN | ENABLE_BATCHEDNL) #define DISABLE_ALL_SCAN 0 #define DISABLE_ALL_JOIN 0 @@ -153,9 +157,11 @@ typedef enum HintKeyword HINT_KEYWORD_NOINDEXONLYSCAN, HINT_KEYWORD_NESTLOOP, + HINT_KEYWORD_BATCHEDNL, HINT_KEYWORD_MERGEJOIN, HINT_KEYWORD_HASHJOIN, HINT_KEYWORD_NONESTLOOP, + HINT_KEYWORD_NOBATCHEDNL, HINT_KEYWORD_NOMERGEJOIN, HINT_KEYWORD_NOHASHJOIN, @@ -616,9 +622,11 @@ static const HintParser parsers[] = { {HINT_NOINDEXONLYSCAN, ScanMethodHintCreate, HINT_KEYWORD_NOINDEXONLYSCAN}, {HINT_NESTLOOP, JoinMethodHintCreate, HINT_KEYWORD_NESTLOOP}, + {HINT_BATCHEDNL, JoinMethodHintCreate, HINT_KEYWORD_BATCHEDNL}, {HINT_MERGEJOIN, JoinMethodHintCreate, HINT_KEYWORD_MERGEJOIN}, {HINT_HASHJOIN, JoinMethodHintCreate, HINT_KEYWORD_HASHJOIN}, {HINT_NONESTLOOP, JoinMethodHintCreate, HINT_KEYWORD_NONESTLOOP}, + {HINT_NOBATCHEDNL, JoinMethodHintCreate, HINT_KEYWORD_NOBATCHEDNL}, {HINT_NOMERGEJOIN, JoinMethodHintCreate, HINT_KEYWORD_NOMERGEJOIN}, {HINT_NOHASHJOIN, JoinMethodHintCreate, HINT_KEYWORD_NOHASHJOIN}, @@ -2222,6 +2230,9 @@ JoinMethodHintParse(JoinMethodHint *hint, HintState *hstate, Query *parse, case HINT_KEYWORD_NESTLOOP: hint->enforce_mask = ENABLE_NESTLOOP; break; + case HINT_KEYWORD_BATCHEDNL: + hint->enforce_mask = ENABLE_BATCHEDNL; + break; case HINT_KEYWORD_MERGEJOIN: hint->enforce_mask = ENABLE_MERGEJOIN; break; @@ -2231,6 +2242,9 @@ JoinMethodHintParse(JoinMethodHint *hint, HintState *hstate, Query *parse, case HINT_KEYWORD_NONESTLOOP: hint->enforce_mask = ENABLE_ALL_JOIN ^ ENABLE_NESTLOOP; break; + case HINT_KEYWORD_NOBATCHEDNL: + hint->enforce_mask = ENABLE_ALL_JOIN ^ ENABLE_BATCHEDNL; + break; case HINT_KEYWORD_NOMERGEJOIN: hint->enforce_mask = ENABLE_ALL_JOIN ^ ENABLE_MERGEJOIN; break; @@ -2571,6 +2585,8 @@ get_current_join_mask() mask |= ENABLE_HASHJOIN; if (enable_memoize) mask |= ENABLE_MEMOIZE; + if (yb_enable_batchednl) + mask |= ENABLE_BATCHEDNL; return mask; } @@ -2767,7 +2783,7 @@ set_join_config_options(unsigned char enforce_mask, bool set_memoize, unsigned char mask; if (enforce_mask == ENABLE_NESTLOOP || enforce_mask == ENABLE_MERGEJOIN || - enforce_mask == ENABLE_HASHJOIN) + enforce_mask == ENABLE_HASHJOIN || enforce_mask == ENABLE_BATCHEDNL) mask = enforce_mask; else mask = enforce_mask & current_hint_state->init_join_mask; @@ -2779,6 +2795,8 @@ set_join_config_options(unsigned char enforce_mask, bool set_memoize, if (set_memoize) SET_CONFIG_OPTION("enable_memoize", ENABLE_MEMOIZE); + SET_CONFIG_OPTION("yb_enable_batchednl", ENABLE_BATCHEDNL); + /* * Hash join may be rejected for the reason of estimated memory usage. Try * getting rid of that limitation. diff --git a/sql/base_plan.sql b/sql/base_plan.sql index a9d31162183d..9ef2367542d1 100644 --- a/sql/base_plan.sql +++ b/sql/base_plan.sql @@ -4,10 +4,12 @@ SET search_path TO public; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; -- query type 2 EXPLAIN (COSTS false) SELECT * FROM t1, t4 WHERE t1.val < 10; +-- YB_COMMENT +-- CTID based scans and searches not supported in Yugabyte -- query type 3 -EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; +-- EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; -- query type 4 -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; -- query type 5 EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val; -- query type 6 diff --git a/sql/init.sql b/sql/init.sql index ba14b409d192..b0d585e13349 100644 --- a/sql/init.sql +++ b/sql/init.sql @@ -9,6 +9,8 @@ CREATE TABLE t3 (id int PRIMARY KEY, val int); CREATE TABLE t4 (id int PRIMARY KEY, val int); CREATE TABLE t5 (id int PRIMARY KEY, val int); CREATE TABLE p1 (id int PRIMARY KEY, val int); +-- TODOs INHERITANCE is unsupported +/* CREATE TABLE p1_c1 (LIKE p1 INCLUDING ALL, CHECK (id <= 100)) INHERITS(p1); CREATE TABLE p1_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 100 AND id <= 200)) INHERITS(p1); CREATE TABLE p1_c3 (LIKE p1 INCLUDING ALL, CHECK (id > 200 AND id <= 300)) INHERITS(p1); @@ -17,6 +19,7 @@ CREATE TABLE p1_c1_c1 (LIKE p1 INCLUDING ALL, CHECK (id <= 50)) INHERITS(p1_c1); CREATE TABLE p1_c1_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 50 AND id <= 100)) INHERITS(p1_c1); CREATE TABLE p1_c3_c1 (LIKE p1 INCLUDING ALL, CHECK (id > 200 AND id <= 250)) INHERITS(p1_c3); CREATE TABLE p1_c3_c2 (LIKE p1 INCLUDING ALL, CHECK (id > 250 AND id <= 300)) INHERITS(p1_c3); +*/ CREATE TABLE p2 (id int PRIMARY KEY, val text); CREATE INDEX p2_id_val_idx ON p2 (id, val); CREATE UNIQUE INDEX p2_val_idx ON p2 (val); @@ -26,11 +29,13 @@ CREATE INDEX p2_val_id_idx ON p2 (val, id); CREATE INDEX p2_val_idx2 ON p2 (val COLLATE "C"); CREATE INDEX p2_val_idx3 ON p2 (val varchar_ops); CREATE INDEX p2_val_idx4 ON p2 (val DESC NULLS LAST); -CREATE INDEX p2_val_idx5 ON p2 (val NULLS FIRST); +CREATE INDEX p2_val_idx5 ON p2 (val ASC NULLS FIRST); CREATE INDEX p2_expr ON p2 ((val < '120')); CREATE INDEX p2_expr2 ON p2 ((id * 2 < 120)); CREATE INDEX p2_val_idx6 ON p2 (val) WHERE val >= '50' AND val < '51'; CREATE INDEX p2_val_idx7 ON p2 (val) WHERE id < 120; +-- TODOs INHERITANCE is unsupported +/* CREATE TABLE p2_c1 (LIKE p2 INCLUDING ALL, CHECK (id <= 100)) INHERITS(p2); CREATE TABLE p2_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 100 AND id <= 200)) INHERITS(p2); CREATE TABLE p2_c3 (LIKE p2 INCLUDING ALL, CHECK (id > 200 AND id <= 300)) INHERITS(p2); @@ -39,6 +44,7 @@ CREATE TABLE p2_c1_c1 (LIKE p2 INCLUDING ALL, CHECK (id <= 50)) INHERITS(p2_c1); CREATE TABLE p2_c1_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 50 AND id <= 100)) INHERITS(p2_c1); CREATE TABLE p2_c3_c1 (LIKE p2 INCLUDING ALL, CHECK (id > 200 AND id <= 250)) INHERITS(p2_c3); CREATE TABLE p2_c3_c2 (LIKE p2 INCLUDING ALL, CHECK (id > 250 AND id <= 300)) INHERITS(p2_c3); +*/ CREATE TABLE s0.t1 (id int PRIMARY KEY, val int); INSERT INTO t1 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t; @@ -46,6 +52,8 @@ INSERT INTO t2 SELECT i, i % 10 FROM (SELECT generate_series(1, 1000) i) t; INSERT INTO t3 SELECT i, i FROM (SELECT generate_series(1, 100) i) t; INSERT INTO t4 SELECT i, i FROM (SELECT generate_series(1, 10) i) t; INSERT INTO t5 SELECT i, i % 100 FROM (SELECT generate_series(1, 10000) i) t; +-- Queries that are dependent on tables that are created using including all and inherits. +/* INSERT INTO p1_c1_c1 SELECT i, i % 100 FROM (SELECT generate_series(1, 50) i) t; INSERT INTO p1_c1_c2 SELECT i, i % 100 FROM (SELECT generate_series(51, 100) i) t; INSERT INTO p1_c2 SELECT i, i % 100 FROM (SELECT generate_series(101, 200) i) t; @@ -58,6 +66,7 @@ INSERT INTO p2_c2 SELECT i, i % 100 FROM (SELECT generate_series(101, 200) i) t; INSERT INTO p2_c3_c1 SELECT i, i % 100 FROM (SELECT generate_series(201, 250) i) t; INSERT INTO p2_c3_c2 SELECT i, i % 100 FROM (SELECT generate_series(251, 300) i) t; INSERT INTO p2_c4 SELECT i, i % 100 FROM (SELECT generate_series(301, 400) i) t; +*/ CREATE INDEX t1_val ON t1 (val); CREATE INDEX t2_val ON t2 (val); @@ -65,15 +74,22 @@ CREATE INDEX t5_id1 ON t5 (id); CREATE INDEX t5_id2 ON t5 (id); CREATE INDEX t5_id3 ON t5 (id); CREATE INDEX t5_val ON t5 (val); +-- Queries that are dependent on tables that are created using including all and inherits. +/* DROP INDEX p2_c4_val_id_idx; +*/ CREATE INDEX p2_id2_val ON p2 (id, id, val); +/* CREATE INDEX p2_c1_id2_val ON p2_c1 (id, id, val); CREATE INDEX p2_c2_id2_val ON p2_c2 (id, id, val); +*/ CREATE INDEX p2_val2_id ON p2 (val, id, val); CREATE INDEX t5_idaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ON t5 (id); CREATE INDEX p1_val1 ON p1 (val); CREATE INDEX p1_val2 ON p1 (val); CREATE INDEX p1_val3 ON p1 (val); +-- Queries that are dependent on tables that are created using including all and inherits. +/* CREATE INDEX p1_c1_val1 ON p1_c1 (val); CREATE INDEX p1_c1_val2 ON p1_c1 (val); CREATE INDEX p1_c1_val3 ON p1_c1 (val); @@ -98,6 +114,7 @@ CREATE INDEX p1_c3_c2_val3 ON p1_c3_c2 (val); CREATE INDEX p1_c4_val1 ON p1_c4 (val); CREATE INDEX p1_c4_val2 ON p1_c4 (val); CREATE INDEX p1_c4_val3 ON p1_c4 (val); +*/ ANALYZE t1; ANALYZE t2; @@ -105,8 +122,10 @@ ANALYZE t3; ANALYZE t4; ANALYZE t5; ANALYZE p1; +/* ANALYZE p1_c1; ANALYZE p1_c2; +*/ ANALYZE p2; CREATE VIEW v1 AS SELECT id, val FROM t1; @@ -124,10 +143,12 @@ ALTER SYSTEM SET effective_cache_size TO 16384; SELECT pg_reload_conf(); SET effective_cache_size TO 16384; +-- YB: modify view to avoid yb_ settings. CREATE VIEW settings AS SELECT name, setting, category FROM pg_settings WHERE category LIKE 'Query Tuning%' + AND name NOT LIKE 'yb_%' OR name = 'client_min_messages' ORDER BY category, name; SELECT * FROM settings; diff --git a/sql/pg_hint_plan.sql b/sql/pg_hint_plan.sql index f41d8d912fa6..d21eaa048f86 100644 --- a/sql/pg_hint_plan.sql +++ b/sql/pg_hint_plan.sql @@ -1,7 +1,11 @@ +-- This test is derived from the pg_hint_plan test in +-- . SET search_path TO public; SET client_min_messages TO log; \set SHOW_CONTEXT always +-- In general, for postgres since t1.id and t2.id is sorted, merge joins should be optimal. +-- However, since YB does not support merge join nested loop joins will be used. EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val; @@ -34,6 +38,7 @@ RESET pg_hint_plan.enable_hint_table; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.val = t2.val; +-- pg_hint_plan when enabled recognizes Test as an unknown keyword /*+ Test (t1 t2) */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; SET pg_hint_plan.enable_hint TO off; @@ -41,14 +46,18 @@ SET pg_hint_plan.enable_hint TO off; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; SET pg_hint_plan.enable_hint TO on; +-- Planner Method Configuration parameters can be controlled as a part of pg_hint_plan comments. +-- pg_hint_plan comment formatting wrong /*Set(enable_indexscan off)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; +-- pg_hint_plan comment formatting wrong --+Set(enable_indexscan off) EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+Set(enable_indexscan off) /* nest comment */ */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+Set(enable_indexscan off)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; +-- pg_hint_plan_comments can be used in between queries EXPLAIN (COSTS false) /*+Set(enable_indexscan off)*/ SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+ Set(enable_indexscan off) Set(enable_hashjoin off) */ @@ -56,15 +65,17 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+ Set ( enable_indexscan off ) */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; -/*+ - Set - ( - enable_indexscan - off - ) - */ +/*+ + Set + ( + enable_indexscan + off + ) + */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; -/*+ Set(enable_indexscan off)Set(enable_nestloop off)Set(enable_mergejoin off) +-- YB_COMMENT +-- Output of this query is different from postgres. Will change once YB optimizes planner +/*+ Set(enable_indexscan off)Set(enable_nestloop off)Set(enable_mergejoin off) Set(enable_seqscan off) */ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -76,12 +87,16 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+SeqScan() */ SELECT 1; +-- SeqScan takes only 1 argument. Hence it appears in error hint and not in used hint in +-- the description. /*+SeqScan(t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+SeqScan(t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+SeqScan(t1)IndexScan(t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; +-- YB_COMMENT +-- Bitmapscan is not supported by YB /*+BitmapScan(t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+BitmapScan(t2)NoSeqScan(t1)*/ @@ -91,10 +106,12 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+NoBitmapScan(t1)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t4 WHERE t1.val < 10; -/*+TidScan(t4)*/ -EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; -/*+NoTidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; +-- YB_COMMENT +-- Tid scan not supported by YB +-- /*+TidScan(t4)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t3, t4 WHERE t3.id = t4.id AND t4.ctid = '(1,1)'; +-- /*+NoTidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)'; /*+ NestLoop() */ SELECT 1; /*+ NestLoop(x) */ SELECT 1; @@ -102,6 +119,12 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1 EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; /*+NestLoop(t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; + +-- YB_COMMENT +-- Because the plan defaults to a BNL in Yugabyte, add a NoYbBatchedNL test +/*+NoYbBatchedNL(t1 t2)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; + /*+NoMergeJoin(t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; @@ -114,6 +137,26 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t3 WHERE t1.val = t3.val; /*+MergeJoin(t4 t1 t2 t3)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; +-- YB_COMMENT +-- If Merge joins were present, the inner two tables will utilize merge joins as id is a sorted +-- column. Since YB does not support merge join, the inner tables are joined using Nested Loop. +-- Output after Merge join support will look like this. +-- QUERY PLAN +-- -------------------------------------------------------- +-- Hash Join +-- Hash Cond: (t3.id = t1.id) +-- -> Seq Scan on t3 +-- -> Hash +-- -> Merge Join +-- Merge Cond: (t1.id = t4.id) +-- -> Merge Join +-- Merge Cond: (t1.id = t2.id) +-- -> Index Scan using t1_pkey on t1 +-- -> Index Scan using t2_pkey on t2 +-- -> Sort +-- Sort Key: t4.id +-- -> Seq Scan on t4 +-- (13 rows) /*+HashJoin(t3 t4 t1 t2)*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id; /*+NestLoop(t2 t3 t4 t1) IndexScan(t3)*/ @@ -148,340 +191,344 @@ EXPLAIN (COSTS false) SELECT * FROM t1, (VALUES(1,1),(2,2),(3,3)) AS t2(id,val) -- single table scan hint test EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- YB_COMMENT +-- BitmapScan is not supported by YB /*+BitmapScan(v_1)*/ EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -/*+BitmapScan(v_2)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -/*+BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -/*+BitmapScan(v_1)BitmapScan(v_2)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -/*+BitmapScan(v_1)BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -/*+BitmapScan(v_2)BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); -/*+BitmapScan(v_1)BitmapScan(v_2)BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); - +-- /*+BitmapScan(v_2)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_1)BitmapScan(v_2)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_1)BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_2)BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- /*+BitmapScan(v_1)BitmapScan(v_2)BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT (SELECT max(id) FROM t1 v_1 WHERE id < 10), id FROM v1 WHERE v1.id = (SELECT max(id) FROM t1 v_2 WHERE id < 10); +-- +-- YB_COMMENT +-- CTID based scans and searches not supported in Yugabyte -- full scan hint pattern test EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+SeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+IndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+TidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+NoSeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+NoIndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+NoBitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; -/*+NoTidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; - -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+SeqScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+IndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+IndexScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+BitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+BitmapScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+TidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+TidScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+NoSeqScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoSeqScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+NoIndexScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoIndexScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+NoBitmapScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoBitmapScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - -/*+NoTidScan(t1)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) SeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) IndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) TidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) NoSeqScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) NoIndexScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) NoBitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; -/*+NoTidScan(t1) NoTidScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; - --- additional test -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; -/*+BitmapScan(t1) BitmapScan(t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; - --- outer join test -EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); -/*+MergeJoin(t1 t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); --- Cannot work -/*+NestLoop(t1 t2)*/ -EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); - --- inheritance tables test -SET constraint_exclusion TO off; -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -SET constraint_exclusion TO on; -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -SET constraint_exclusion TO off; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -SET constraint_exclusion TO on; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; - -SET constraint_exclusion TO off; -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -SET constraint_exclusion TO on; -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -SET constraint_exclusion TO off; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+NestLoop(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+MergeJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+HashJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -SET constraint_exclusion TO on; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+NestLoop(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+MergeJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; -/*+HashJoin(p1 t1)*/ -EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; - -SET constraint_exclusion TO off; -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -SET constraint_exclusion TO on; -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -SET constraint_exclusion TO off; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+NestLoop(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; -/*+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; -/*+HashJoin(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; -SET constraint_exclusion TO on; -/*+SeqScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+IndexScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+BitmapScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+TidScan(p1)*/ -EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; -/*+NestLoop(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; -/*+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; -/*+HashJoin(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; - -SET constraint_exclusion TO off; -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; -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; -SET constraint_exclusion TO off; -/*+SeqScan(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; -/*+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; -/*+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; -/*+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; -SET constraint_exclusion TO on; -/*+SeqScan(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; -/*+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; -/*+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; -/*+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; +-- /*+SeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+IndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+TidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoSeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoIndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoBitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- /*+NoTidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id < 10 AND ctid = '(1,1)'; +-- +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+SeqScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+IndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+IndexScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+BitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+BitmapScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+TidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+TidScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoSeqScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoSeqScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoIndexScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoIndexScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoBitmapScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoBitmapScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- /*+NoTidScan(t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) SeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) IndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) TidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoSeqScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoIndexScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoBitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- /*+NoTidScan(t1) NoTidScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- +-- -- additional test +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; +-- /*+BitmapScan(t1) BitmapScan(t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)' AND t1.id < 10 AND t2.id < 10; +-- +-- -- outer join test +-- EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); +-- /*+MergeJoin(t1 t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); +-- -- Cannot work +-- /*+NestLoop(t1 t2)*/ +-- EXPLAIN (COSTS false) SELECT * FROM t1 FULL OUTER JOIN t2 ON (t1.id = t2.id); +-- +-- -- inheritance tables test +-- SET constraint_exclusion TO off; +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO on; +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- +-- SET constraint_exclusion TO off; +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- SET constraint_exclusion TO on; +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+NestLoop(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+MergeJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+HashJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+NestLoop(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+MergeJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- /*+HashJoin(p1 t1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p1, t1 WHERE p1.id >= 50 AND p1.id <= 51 AND p1.ctid = '(1,1)' AND p1.id = t1.id AND t1.id < 10; +-- +-- SET constraint_exclusion TO off; +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO on; +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+NestLoop(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; +-- /*+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; +-- /*+HashJoin(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; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+IndexScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+BitmapScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+TidScan(p1)*/ +-- EXPLAIN (COSTS false) SELECT * FROM ONLY p1 WHERE id >= 50 AND id <= 51 AND p1.ctid = '(1,1)'; +-- /*+NestLoop(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; +-- /*+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; +-- /*+HashJoin(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; +-- +-- SET constraint_exclusion TO off; +-- 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; +-- 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; +-- SET constraint_exclusion TO off; +-- /*+SeqScan(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; +-- /*+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; +-- /*+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; +-- /*+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; +-- SET constraint_exclusion TO on; +-- /*+SeqScan(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; +-- /*+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; +-- /*+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; +-- /*+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; -- IndexScan is safe for unordered indexes CREATE TABLE ischk (a text, b tsvector) PARTITION BY LIST(a); @@ -497,8 +544,10 @@ DROP TABLE ischk; EXPLAIN (COSTS false) SELECT * FROM t1 """t1 ) ", t2 "t 2 """, t3 "T3" WHERE """t1 ) ".id = "t 2 """.id AND """t1 ) ".id = "T3".id; -- duplicate hint test -/*+SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)TidScan(t1)TidScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)*/ -EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id AND t1.ctid = '(1,1)' AND t2.ctid = '(1,1)'; +-- YB_COMMENT +-- Removed TidScan because CTID based scans and searches not supported in Yugabyte +/*+SeqScan(t1)SeqScan(t2)IndexScan(t1)IndexScan(t2)BitmapScan(t1)BitmapScan(t2)HashJoin(t1 t2)NestLoop(t2 t1)MergeJoin(t1 t2)Leading(t1 t2)Leading(t2 t1)Set(enable_seqscan off)Set(enable_mergejoin on)Set(enable_seqscan on)*/ +EXPLAIN (COSTS false) SELECT * FROM t1, t2 WHERE t1.id = t2.id; -- sub query Leading hint test SET from_collapse_limit TO 100; @@ -512,7 +561,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/ EXPLAIN (COSTS false) @@ -524,7 +573,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/ EXPLAIN (COSTS false) @@ -536,7 +585,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/ EXPLAIN (COSTS false) @@ -548,7 +597,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/ EXPLAIN (COSTS false) @@ -560,7 +609,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); SET from_collapse_limit TO 1; @@ -573,7 +622,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)*/ EXPLAIN (COSTS false) @@ -585,7 +634,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t1_1 t1_2 t1_4 t1_5)*/ EXPLAIN (COSTS false) @@ -597,7 +646,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(a t3_2 t3_5 t2_2 c1_1 t3_4 t3_3 t2_3 t2_4 t1_3 t2_5 t1_2 t3_1 t1_4 t2_1 t1_5 t1_1)*/ EXPLAIN (COSTS false) @@ -609,7 +658,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); /*+HashJoin(t1_1 t3_1)MergeJoin(t1_3 t3_3)NestLoop(t1_2 t2_2)NestLoop(t1_4 t2_4)NestLoop(t1_5 t2_5)Leading(t3_5 t2_5 t1_5)Leading(t3_2 t2_2 t1_2)Leading(t3_4 t2_4 t1_4)Leading(c1_1 t3_3 t2_3 t1_3 t3_1 t2_1 t1_1)*/ EXPLAIN (COSTS false) @@ -621,7 +670,7 @@ SELECT max(t1_2.id) FROM t1 t1_2, t2 t2_2, t3 t3_2 WHERE t1_2.id = t2_2.id AND t ) FROM t1 t1_1, t2 t2_1, t3 t3_1, ( SELECT t1_3.id FROM t1 t1_3, t2 t2_3, t3 t3_3 WHERE t1_3.id = t2_3.id AND t2_3.id = t3_3.id ) v1_1(id), c1_1 WHERE t1_1.id = t2_1.id AND t2_1.id = t3_1.id AND t2_1.id = v1_1.id AND v1_1.id = c1_1.id AND t1_1.id = ( -SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id +SELECT max(t1_4.id) FROM t1 t1_4, t2 t2_4, t3 t3_4 WHERE t1_4.id = t2_4.id AND t2_4.id = t3_4.id ); -- ambiguous error @@ -755,52 +804,54 @@ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t /*+Leading((((t5 t4)t3)(t2 t1)))*/ EXPLAIN (COSTS false) SELECT * FROM t1, t2, t3, t4, t5 WHERE t1.id = t2.id AND t1.id = t3.id AND t1.id = t4.id AND t1.id = t5.id; +-- YB_COMMENT +-- Inheritance not supporte by Yugabyte -- inherite table test to specify the index's name EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_pkey)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_id_val_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_val_id_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; - -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; - +-- /*+IndexScan(p2 p2_pkey)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_id_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val_id_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- -- 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)'; -/*+IndexScan(p2 p2_pkey)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_id2_val)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_val2_id)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; - -/*+IndexScan(p2 p2_pkey)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_c1_id_val_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_pkey p2_c1_id_val_idx)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_pkey no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_c1_id_val_idx no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist)*/ -EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; - -/*+IndexScan(p2 p2_val_idx)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_expr)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_val_idx6)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; -/*+IndexScan(p2 p2_val_idx p2_val_idx6)*/ -EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; - +-- /*+ IndexScan(p2 p2_val)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_id2_val)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val2_id)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- +-- /*+IndexScan(p2 p2_pkey)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_c1_id_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey p2_c1_id_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_c1_id_val_idx no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_pkey p2_c1_id_val_idx no_exist)*/ +-- EXPLAIN (COSTS false) SELECT * FROM p2 WHERE id >= 50 AND id <= 51 AND p2.ctid = '(1,1)'; +-- +-- /*+IndexScan(p2 p2_val_idx)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_expr)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val_idx6)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- /*+IndexScan(p2 p2_val_idx p2_val_idx6)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p2 WHERE val >= '50' AND val <= '51' AND p2.ctid = '(1,1)'; +-- -- regular expression -- ordinary table EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; @@ -824,6 +875,9 @@ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; /*+ IndexOnlyScan(t5 t5_id[0-9].*)*/ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; + +-- YB_COMMENT +-- Yugabyte does not support bitmap scan /*+ BitmapScanRegexp(t5 t5_[^i].*)*/ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; /*+ BitmapScanRegexp(t5 t5_id[0-9].*)*/ @@ -835,33 +889,34 @@ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; /*+ BitmapScan(t5 t5_id[0-9].*)*/ EXPLAIN (COSTS false) SELECT id FROM t5 WHERE id = 1; +-- YB_COMMENT -- Inheritance EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexScanRegexp(p1 p1_.*[^0-9]$)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexScanRegexp(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexScanRegexp(p1 p1[^_].*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexScan(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexOnlyScanRegexp(p1 p1_.*[^0-9]$)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexOnlyScanRegexp(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexOnlyScanRegexp(p1 p1[^_].*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ IndexOnlyScan(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ BitmapScanRegexp(p1 p1_.*[^0-9]$)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ BitmapScanRegexp(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ BitmapScanRegexp(p1 p1[^_].*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; -/*+ BitmapScan(p1 p1_.*val2.*)*/ -EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; - +-- /*+ IndexScanRegexp(p1 p1_.*[^0-9]$)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexScanRegexp(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexScanRegexp(p1 p1[^_].*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexScan(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScanRegexp(p1 p1_.*[^0-9]$)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScanRegexp(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScanRegexp(p1 p1[^_].*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ IndexOnlyScan(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScanRegexp(p1 p1_.*[^0-9]$)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScanRegexp(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScanRegexp(p1 p1[^_].*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- /*+ BitmapScan(p1 p1_.*val2.*)*/ +-- EXPLAIN (COSTS false) SELECT val FROM p1 WHERE val = 1; +-- -- search from hint table INSERT INTO hint_plan.hints (norm_query_string, application_name, hints) VALUES ('EXPLAIN (COSTS false) SELECT * FROM t1 WHERE t1.id = ?;', '', 'SeqScan(t1)'); INSERT INTO hint_plan.hints (norm_query_string, application_name, hints) VALUES ('EXPLAIN (COSTS false) SELECT id FROM t1 WHERE t1.id = ?;', '', 'IndexScan(t1)'); @@ -995,171 +1050,175 @@ BEGIN END; $$ LANGUAGE plpgsql; +-- YB_COMMENT +-- pg_stat_user_tables not supportd by YB -- Dynamic query in pl/pgsql -CREATE OR REPLACE FUNCTION dynsql1(x int) RETURNS int AS $$ -DECLARE c int; -BEGIN - EXECUTE '/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1' - INTO c USING x; - RETURN c; -END; -$$ VOLATILE LANGUAGE plpgsql; -vacuum analyze t1; -SET pg_hint_plan.enable_hint = false; -SELECT pg_sleep(1); -SELECT reset_stats_and_wait(); -SELECT dynsql1(9000); -SELECT pg_sleep(1); -SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; -SET pg_hint_plan.enable_hint = true; -SELECT reset_stats_and_wait(); -SELECT dynsql1(9000); -SELECT pg_sleep(1); -SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; - --- Looped dynamic query in pl/pgsql -CREATE OR REPLACE FUNCTION dynsql2(x int, OUT r int) AS $$ -DECLARE - c text; - s int; -BEGIN - r := 0; - FOR c IN SELECT f.f FROM (VALUES ('p1_c1'), ('p1_c2')) f(f) LOOP - FOR s IN EXECUTE '/*+ IndexScan(' || c || ' ' || c || '_pkey) */ SELECT sum(val) FROM ' || c || ' WHERE id < ' || x LOOP - r := r + s; - END LOOP; - END LOOP; -END; -$$ VOLATILE LANGUAGE plpgsql; -SET pg_hint_plan.enable_hint = false; -SELECT reset_stats_and_wait(); -SELECT dynsql2(9000); -SELECT pg_sleep(1); --- one of the index scans happened while planning. -SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); -SET pg_hint_plan.enable_hint = true; -SELECT reset_stats_and_wait(); -SELECT dynsql2(9000); -SELECT pg_sleep(1); --- the index scan happened while planning. -SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); - --- Subqueries on inheritance tables under UNION -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION ALL -SELECT val::int FROM p2 WHERE id < 1000; - -/*+ IndexScan(p1 p1_val2) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION ALL -SELECT val::int FROM p2 WHERE id < 1000; - -/*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION ALL -SELECT val::int FROM p2 WHERE id < 1000; - --- union all case -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION -SELECT val::int FROM p2 WHERE id < 1000; - -/*+ IndexScan(p2 p2_id_val_idx) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION -SELECT val::int FROM p2 WHERE id < 1000; - -/*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ -EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 -UNION -SELECT val::int FROM p2 WHERE id < 1000; - +-- CREATE OR REPLACE FUNCTION dynsql1(x int) RETURNS int AS $$ +-- DECLARE c int; +-- BEGIN +-- EXECUTE '/*+ IndexScan(t1) */ SELECT count(*) FROM t1 WHERE id < $1' +-- INTO c USING x; +-- RETURN c; +-- END; +-- $$ VOLATILE LANGUAGE plpgsql; +-- vacuum analyze t1; +-- SET pg_hint_plan.enable_hint = false; +-- SELECT pg_sleep(1); +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql1(9000); +-- SELECT pg_sleep(1); +-- SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; +-- SET pg_hint_plan.enable_hint = true; +-- SELECT pg_sleep(1); +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql1(9000); +-- SELECT pg_sleep(1); +-- SELECT relname, seq_scan > 0 as seq_scan, idx_scan > 0 as idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND relname = 't1'; +-- +-- Dependent on inheritance +-- -- Looped dynamic query in pl/pgsql +-- CREATE OR REPLACE FUNCTION dynsql2(x int, OUT r int) AS $$ +-- DECLARE +-- c text; +-- s int; +-- BEGIN +-- r := 0; +-- FOR c IN SELECT f.f FROM (VALUES ('p1_c1'), ('p1_c2')) f(f) LOOP +-- FOR s IN EXECUTE '/*+ IndexScan(' || c || ' ' || c || '_pkey) */ SELECT sum(val) FROM ' || c || ' WHERE id < ' || x LOOP +-- r := r + s; +-- END LOOP; +-- END LOOP; +-- END; +-- $$ VOLATILE LANGUAGE plpgsql; +-- SET pg_hint_plan.enable_hint = false; +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql2(9000); +-- SELECT pg_sleep(1); +-- -- one of the index scans happened while planning. +-- SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); +-- SET pg_hint_plan.enable_hint = true; +-- SELECT reset_stats_and_wait(); +-- SELECT dynsql2(9000); +-- SELECT pg_sleep(1); +-- -- the index scan happened while planning. +-- SELECT relname, seq_scan, idx_scan FROM pg_stat_user_tables WHERE schemaname = 'public' AND (relname = 'p1_c1' OR relname = 'p1_c2'); +-- +-- -- Subqueries on inheritance tables under UNION +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION ALL +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p1 p1_val2) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION ALL +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION ALL +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- -- union all case +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p2 p2_id_val_idx) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION +-- SELECT val::int FROM p2 WHERE id < 1000; +-- +-- /*+ IndexScan(p1 p1_val2) IndexScan(p2 p2_id_val_idx) */ +-- EXPLAIN (COSTS off) SELECT val FROM p1 WHERE val < 1000 +-- UNION +-- SELECT val::int FROM p2 WHERE id < 1000; +-- -- -- Rows hint tests -- -- Explain result includes "Planning time" if COSTS is enabled, but -- this test needs it enabled for get rows count. So do tests via psql -- and grep -v the mutable line. - --- Parse error check -/*+ Rows() */ SELECT 1; -/*+ Rows(x) */ SELECT 1; - --- value types -\o results/pg_hint_plan.tmpout -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 #99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 +99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 -99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 *99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 *0.01) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 #aa) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 /99) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - --- round up to 1 -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 -99999) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - --- complex join tree -\o results/pg_hint_plan.tmpout -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t2 #22) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); -\o -\! sql/maskout.sh results/pg_hint_plan.tmpout - -\o results/pg_hint_plan.tmpout -/*+ Rows(t1 t3 *10) */ -EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); -\o -set max_parallel_workers_per_gather to DEFAULT; -\! sql/maskout.sh results/pg_hint_plan.tmpout -\! rm results/pg_hint_plan.tmpout - +-- +-- -- Parse error check +-- /*+ Rows() */ SELECT 1; +-- /*+ Rows(x) */ SELECT 1; +-- +-- -- value types +-- \o results/pg_hint_plan.tmpout +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 #99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 +99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 -99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 *99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 *0.01) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 #aa) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 /99) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); -- ERROR +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- -- round up to 1 +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 -99999) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- -- complex join tree +-- \o results/pg_hint_plan.tmpout +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t2 #22) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); +-- \o +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- +-- \o results/pg_hint_plan.tmpout +-- /*+ Rows(t1 t3 *10) */ +-- EXPLAIN SELECT * FROM t1 JOIN t2 ON (t1.id = t2.id) JOIN t3 ON (t3.id = t2.id); +-- \o +-- set max_parallel_workers_per_gather to DEFAULT; +-- \! sql/maskout.sh results/pg_hint_plan.tmpout +-- \! rm results/pg_hint_plan.tmpout +-- -- hint error level set client_min_messages to 'DEBUG1'; /*+ SeqScan( */ SELECT 1; diff --git a/yb_schedule b/yb_schedule new file mode 100644 index 000000000000..34b051f779e7 --- /dev/null +++ b/yb_schedule @@ -0,0 +1,10 @@ +# third-party-extensions/pg_hint_plan/yb_schedule + +test: oldextversions +test: init +test: base_plan +test: pg_hint_plan +test: hints_anywhere +# TODO(#TBD): These tests are broken in upstream. Once a hint is given by a statement, all +# subsequent statements continue to use the same hints. +# test: plpgsql