diff --git a/expected/ut-A.out b/expected/ut-A.out index d942f503..6e56cf52 100644 --- a/expected/ut-A.out +++ b/expected/ut-A.out @@ -4758,14 +4758,14 @@ CREATE INDEX ON s1.tpc(a); PREPARE p1 AS SELECT * FROM s1.tpc WHERE a < 999; /*+ IndexScan(tpc) */PREPARE p2 AS SELECT * FROM s1.tpc WHERE a < 999; /*+ SeqScan(tpc) */PREPARE p3(int) AS SELECT * FROM s1.tpc WHERE a = $1; -EXPLAIN EXECUTE p1; - QUERY PLAN ------------------------------------------------------- - Seq Scan on tpc (cost=0.00..17.50 rows=333 width=4) +EXPLAIN (COSTS false) EXECUTE p1; + QUERY PLAN +--------------------- + Seq Scan on tpc Filter: (a < 999) (2 rows) -EXPLAIN EXECUTE p2; +EXPLAIN (COSTS false) EXECUTE p2; LOG: pg_hint_plan: used hint: IndexScan(tpc) @@ -4773,13 +4773,13 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------- - Index Scan using tpc_a_idx on tpc (cost=0.28..34.10 rows=333 width=4) + QUERY PLAN +----------------------------------- + Index Scan using tpc_a_idx on tpc Index Cond: (a < 999) (2 rows) -EXPLAIN EXECUTE p3(500); +EXPLAIN (COSTS false) EXECUTE p3(500); LOG: pg_hint_plan: used hint: SeqScan(tpc) @@ -4787,9 +4787,9 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on tpc (cost=0.00..17.50 rows=5 width=4) + QUERY PLAN +--------------------- + Seq Scan on tpc Filter: (a = 500) (2 rows) @@ -4797,14 +4797,14 @@ error hint: DROP TABLE s1.tpc; CREATE TABLE s1.tpc AS SELECT a FROM generate_series(0, 999) a; CREATE INDEX ON s1.tpc(a); -EXPLAIN EXECUTE p1; - QUERY PLAN ------------------------------------------------------- - Seq Scan on tpc (cost=0.00..17.50 rows=333 width=4) +EXPLAIN (COSTS false) EXECUTE p1; + QUERY PLAN +--------------------- + Seq Scan on tpc Filter: (a < 999) (2 rows) -EXPLAIN EXECUTE p2; +EXPLAIN (COSTS false) EXECUTE p2; LOG: pg_hint_plan: used hint: IndexScan(tpc) @@ -4812,13 +4812,13 @@ not used hint: duplication hint: error hint: - QUERY PLAN ------------------------------------------------------------------------- - Index Scan using tpc_a_idx on tpc (cost=0.28..34.10 rows=333 width=4) + QUERY PLAN +----------------------------------- + Index Scan using tpc_a_idx on tpc Index Cond: (a < 999) (2 rows) -EXPLAIN EXECUTE p3(500); +EXPLAIN (COSTS false) EXECUTE p3(500); LOG: pg_hint_plan: used hint: SeqScan(tpc) @@ -4826,9 +4826,9 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on tpc (cost=0.00..17.50 rows=5 width=4) + QUERY PLAN +--------------------- + Seq Scan on tpc Filter: (a = 500) (2 rows) diff --git a/expected/ut-T.out b/expected/ut-T.out index 8b5f5658..d74ba804 100644 --- a/expected/ut-T.out +++ b/expected/ut-T.out @@ -6,47 +6,47 @@ SET pg_hint_plan.debug_print TO on; SET client_min_messages TO LOG; SET search_path TO public; -- test for get_query_string -INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); +INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); INSERT INTO hint_plan.hints VALUES(DEFAULT,'PREPARE p1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); -INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); -INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); +INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN (COSTS false) DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); +INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN (COSTS false) CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -- These queries uses IndexScan without hints SET pg_hint_plan.enable_hint_table to off; -EXPLAIN SELECT * FROM t1 WHERE id = 100; - QUERY PLAN ------------------------------------------------------------------- - Index Scan using t1_pkey on t1 (cost=0.29..8.30 rows=1 width=8) +EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = 100; + QUERY PLAN +-------------------------------- + Index Scan using t1_pkey on t1 Index Cond: (id = 100) (2 rows) -EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; - QUERY PLAN ------------------------------------------------------------------- - Index Scan using t1_pkey on t1 (cost=0.29..8.30 rows=1 width=8) +EXPLAIN (COSTS false) DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; + QUERY PLAN +-------------------------------- + Index Scan using t1_pkey on t1 Index Cond: (id = 100) (2 rows) -EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; - QUERY PLAN ------------------------------------------------------------------- - Index Scan using t1_pkey on t1 (cost=0.29..8.30 rows=1 width=8) +EXPLAIN (COSTS false) CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; + QUERY PLAN +-------------------------------- + Index Scan using t1_pkey on t1 Index Cond: (id = 100) (2 rows) -EXPLAIN EXECUTE p1; - QUERY PLAN ------------------------------------------------------------------- - Index Scan using t1_pkey on t1 (cost=0.29..8.30 rows=1 width=8) +EXPLAIN (COSTS false) EXECUTE p1; + QUERY PLAN +-------------------------------- + Index Scan using t1_pkey on t1 Index Cond: (id = 100) (2 rows) DEALLOCATE p1; PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -EXPLAIN CREATE TABLE ct1 AS EXECUTE p1; - QUERY PLAN ------------------------------------------------------------------- - Index Scan using t1_pkey on t1 (cost=0.29..8.30 rows=1 width=8) +EXPLAIN (COSTS false) CREATE TABLE ct1 AS EXECUTE p1; + QUERY PLAN +-------------------------------- + Index Scan using t1_pkey on t1 Index Cond: (id = 100) (2 rows) @@ -54,7 +54,7 @@ DEALLOCATE p1; PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -- Forced to use SeqScan by table hints SET pg_hint_plan.enable_hint_table to on; -EXPLAIN SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = 100; LOG: pg_hint_plan: used hint: SeqScan(t1) @@ -62,13 +62,13 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on t1 (cost=0.00..170.00 rows=1 width=8) + QUERY PLAN +---------------------- + Seq Scan on t1 Filter: (id = 100) (2 rows) -EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; LOG: pg_hint_plan: used hint: SeqScan(t1) @@ -76,13 +76,13 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on t1 (cost=0.00..170.00 rows=1 width=8) + QUERY PLAN +---------------------- + Seq Scan on t1 Filter: (id = 100) (2 rows) -EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; LOG: pg_hint_plan: used hint: SeqScan(t1) @@ -90,13 +90,13 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on t1 (cost=0.00..170.00 rows=1 width=8) + QUERY PLAN +---------------------- + Seq Scan on t1 Filter: (id = 100) (2 rows) -EXPLAIN EXECUTE p1; +EXPLAIN (COSTS false) EXECUTE p1; LOG: pg_hint_plan: used hint: SeqScan(t1) @@ -104,15 +104,15 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on t1 (cost=0.00..170.00 rows=1 width=8) + QUERY PLAN +---------------------- + Seq Scan on t1 Filter: (id = 100) (2 rows) DEALLOCATE p1; PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -EXPLAIN CREATE TABLE ct1 AS EXECUTE p1; +EXPLAIN (COSTS false) CREATE TABLE ct1 AS EXECUTE p1; LOG: pg_hint_plan: used hint: SeqScan(t1) @@ -120,9 +120,9 @@ not used hint: duplication hint: error hint: - QUERY PLAN ----------------------------------------------------- - Seq Scan on t1 (cost=0.00..170.00 rows=1 width=8) + QUERY PLAN +---------------------- + Seq Scan on t1 Filter: (id = 100) (2 rows) diff --git a/sql/ut-A.sql b/sql/ut-A.sql index e841fc59..0b54d693 100644 --- a/sql/ut-A.sql +++ b/sql/ut-A.sql @@ -1241,16 +1241,16 @@ CREATE INDEX ON s1.tpc(a); PREPARE p1 AS SELECT * FROM s1.tpc WHERE a < 999; /*+ IndexScan(tpc) */PREPARE p2 AS SELECT * FROM s1.tpc WHERE a < 999; /*+ SeqScan(tpc) */PREPARE p3(int) AS SELECT * FROM s1.tpc WHERE a = $1; -EXPLAIN EXECUTE p1; -EXPLAIN EXECUTE p2; -EXPLAIN EXECUTE p3(500); +EXPLAIN (COSTS false) EXECUTE p1; +EXPLAIN (COSTS false) EXECUTE p2; +EXPLAIN (COSTS false) EXECUTE p3(500); -- The DROP invalidates the plan caches DROP TABLE s1.tpc; CREATE TABLE s1.tpc AS SELECT a FROM generate_series(0, 999) a; CREATE INDEX ON s1.tpc(a); -EXPLAIN EXECUTE p1; -EXPLAIN EXECUTE p2; -EXPLAIN EXECUTE p3(500); +EXPLAIN (COSTS false) EXECUTE p1; +EXPLAIN (COSTS false) EXECUTE p2; +EXPLAIN (COSTS false) EXECUTE p3(500); DEALLOCATE p1; DEALLOCATE p2; DEALLOCATE p3; diff --git a/sql/ut-T.sql b/sql/ut-T.sql index 48a0be3d..aa345ab5 100644 --- a/sql/ut-T.sql +++ b/sql/ut-T.sql @@ -8,36 +8,35 @@ SET client_min_messages TO LOG; SET search_path TO public; -- test for get_query_string -INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); +INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); INSERT INTO hint_plan.hints VALUES(DEFAULT,'PREPARE p1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); -INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); -INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); +INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN (COSTS false) DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); +INSERT INTO hint_plan.hints VALUES(DEFAULT,'EXPLAIN (COSTS false) CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = ?;', '', 'SeqScan(t1)'); PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -- These queries uses IndexScan without hints SET pg_hint_plan.enable_hint_table to off; -EXPLAIN SELECT * FROM t1 WHERE id = 100; -EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; -EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; - -EXPLAIN EXECUTE p1; +EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) EXECUTE p1; DEALLOCATE p1; PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -EXPLAIN CREATE TABLE ct1 AS EXECUTE p1; +EXPLAIN (COSTS false) CREATE TABLE ct1 AS EXECUTE p1; DEALLOCATE p1; PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -- Forced to use SeqScan by table hints SET pg_hint_plan.enable_hint_table to on; -EXPLAIN SELECT * FROM t1 WHERE id = 100; -EXPLAIN DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; -EXPLAIN CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; -EXPLAIN EXECUTE p1; +EXPLAIN (COSTS false) SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) DECLARE c1 CURSOR FOR SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) CREATE TABLE ct1 AS SELECT * FROM t1 WHERE id = 100; +EXPLAIN (COSTS false) EXECUTE p1; DEALLOCATE p1; PREPARE p1 AS SELECT * FROM t1 WHERE id = 100; -EXPLAIN CREATE TABLE ct1 AS EXECUTE p1; +EXPLAIN (COSTS false) CREATE TABLE ct1 AS EXECUTE p1; DEALLOCATE p1;