From a0e154fb3b2357f44bec05471878aab8fb0b710a Mon Sep 17 00:00:00 2001 From: Floris van Nee Date: Thu, 19 Mar 2020 10:27:47 +0100 Subject: [PATCH 3/3] Make planner favor skip in index scans and modify test ouputs This commit hacks the planner to greatly favor skip scans over regular index scans. To be used for testing purposes until proper planner implementation is in place. It also modifies all expected results of the unit tests to add the skip scan attribute in EXPLAIN output. --- .../postgres_fdw/expected/postgres_fdw.out | 47 ++-- src/backend/optimizer/util/pathnode.c | 7 + src/backend/utils/adt/selfuncs.c | 13 +- .../expected/drop-index-concurrently-1.out | 1 + .../isolation/expected/eval-plan-qual.out | 2 + src/test/regress/expected/aggregates.out | 59 +++-- src/test/regress/expected/btree_index.out | 24 +- src/test/regress/expected/cluster.out | 18 +- src/test/regress/expected/create_index.out | 43 +++- src/test/regress/expected/equivclass.out | 72 ++++-- src/test/regress/expected/fast_default.out | 3 +- src/test/regress/expected/foreign_key.out | 4 +- src/test/regress/expected/generated.out | 9 +- src/test/regress/expected/groupingsets.out | 6 +- src/test/regress/expected/index_including.out | 6 +- src/test/regress/expected/inet.out | 12 +- src/test/regress/expected/inherit.out | 149 ++++++++--- src/test/regress/expected/insert_conflict.out | 3 +- src/test/regress/expected/interval.out | 3 +- src/test/regress/expected/join.out | 235 ++++++++++++------ src/test/regress/expected/limit.out | 9 +- src/test/regress/expected/misc_functions.out | 6 +- src/test/regress/expected/partition_join.out | 37 ++- src/test/regress/expected/partition_prune.out | 151 +++++++++-- src/test/regress/expected/plancache.out | 6 +- src/test/regress/expected/portals.out | 3 +- src/test/regress/expected/privileges.out | 15 +- src/test/regress/expected/regex.out | 21 +- src/test/regress/expected/rowsecurity.out | 30 ++- src/test/regress/expected/rowtypes.out | 18 +- src/test/regress/expected/select.out | 29 ++- src/test/regress/expected/select_distinct.out | 15 +- src/test/regress/expected/select_parallel.out | 9 +- src/test/regress/expected/subselect.out | 10 +- src/test/regress/expected/tuplesort.out | 12 +- src/test/regress/expected/union.out | 36 ++- src/test/regress/expected/updatable_views.out | 56 +++-- 37 files changed, 875 insertions(+), 304 deletions(-) diff --git a/contrib/postgres_fdw/expected/postgres_fdw.out b/contrib/postgres_fdw/expected/postgres_fdw.out index 62c2697920..2db85952ec 100644 --- a/contrib/postgres_fdw/expected/postgres_fdw.out +++ b/contrib/postgres_fdw/expected/postgres_fdw.out @@ -444,7 +444,8 @@ EXPLAIN (VERBOSE, COSTS OFF) Remote SQL: SELECT "C 1" FROM "S 1"."T 1" ORDER BY "C 1" ASC NULLS LAST -> Index Only Scan using t1_pkey on "S 1"."T 1" t2 Output: t2."C 1" -(11 rows) + Skip scan: All +(12 rows) SELECT t1.c1, t2."C 1" FROM ft2 t1 JOIN "S 1"."T 1" t2 ON (t1.c1 = t2."C 1") OFFSET 100 LIMIT 10; c1 | C 1 @@ -478,7 +479,8 @@ EXPLAIN (VERBOSE, COSTS OFF) Remote SQL: SELECT "C 1" FROM "S 1"."T 1" ORDER BY "C 1" ASC NULLS LAST -> Index Only Scan using t1_pkey on "S 1"."T 1" t2 Output: t2."C 1" -(11 rows) + Skip scan: All +(12 rows) SELECT t1.c1, t2."C 1" FROM ft2 t1 LEFT JOIN "S 1"."T 1" t2 ON (t1.c1 = t2."C 1") OFFSET 100 LIMIT 10; c1 | C 1 @@ -513,7 +515,8 @@ EXPLAIN (VERBOSE, COSTS OFF) Remote SQL: SELECT r3."C 1" FROM ("S 1"."T 1" r2 INNER JOIN "S 1"."T 1" r3 ON (((r2."C 1" = r3."C 1")))) ORDER BY r2."C 1" ASC NULLS LAST -> Index Only Scan using t1_pkey on "S 1"."T 1" t1 Output: t1."C 1" -(12 rows) + Skip scan: All +(13 rows) SELECT t1."C 1" FROM "S 1"."T 1" t1 left join ft1 t2 join ft2 t3 on (t2.c1 = t3.c1) on (t3.c1 = t1."C 1") OFFSET 100 LIMIT 10; C 1 @@ -549,7 +552,8 @@ EXPLAIN (VERBOSE, COSTS OFF) Remote SQL: SELECT r3."C 1", r2."C 1" FROM ("S 1"."T 1" r3 LEFT JOIN "S 1"."T 1" r2 ON (((r2."C 1" = r3."C 1")))) ORDER BY r3."C 1" ASC NULLS LAST -> Index Only Scan using t1_pkey on "S 1"."T 1" t1 Output: t1."C 1" -(12 rows) + Skip scan: All +(13 rows) SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 left join ft1 t2 full join ft2 t3 on (t2.c1 = t3.c1) on (t3.c1 = t1."C 1") OFFSET 100 LIMIT 10; C 1 | c1 | c1 @@ -583,7 +587,8 @@ EXPLAIN (VERBOSE, COSTS OFF) Remote SQL: SELECT r2."C 1", r3."C 1" FROM ("S 1"."T 1" r2 FULL JOIN "S 1"."T 1" r3 ON (((r2."C 1" = r3."C 1")))) ORDER BY r3."C 1" ASC NULLS LAST -> Index Only Scan using t1_pkey on "S 1"."T 1" t1 Output: t1."C 1" -(12 rows) + Skip scan: All +(13 rows) SELECT t1."C 1", t2.c1, t3.c1 FROM "S 1"."T 1" t1 full join ft1 t2 full join ft2 t3 on (t2.c1 = t3.c1) on (t3.c1 = t1."C 1") OFFSET 100 LIMIT 10; C 1 | c1 | c1 @@ -711,11 +716,12 @@ EXPLAIN (VERBOSE, COSTS OFF) Output: a."C 1", a.c2, a.c3, a.c4, a.c5, a.c6, a.c7, a.c8, b.c1, b.c2, b.c3, b.c4, b.c5, b.c6, b.c7, b.c8 -> Index Scan using t1_pkey on "S 1"."T 1" a Output: a."C 1", a.c2, a.c3, a.c4, a.c5, a.c6, a.c7, a.c8 + Skip scan: All Index Cond: (a."C 1" = 47) -> Foreign Scan on public.ft2 b Output: b.c1, b.c2, b.c3, b.c4, b.c5, b.c6, b.c7, b.c8 Remote SQL: SELECT "C 1", c2, c3, c4, c5, c6, c7, c8 FROM "S 1"."T 1" WHERE (($1::integer = "C 1")) -(8 rows) +(9 rows) SELECT * FROM ft2 a, ft2 b WHERE a.c1 = 47 AND b.c1 = a.c2; c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 | c1 | c2 | c3 | c4 | c5 | c6 | c7 | c8 @@ -2126,6 +2132,7 @@ SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM Output: t1."C 1" -> Index Scan using t1_pkey on "S 1"."T 1" t1 Output: t1."C 1", t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 + Skip scan: All -> HashAggregate Output: t2.c1, t3.c1 Group Key: t2.c1, t3.c1 @@ -2133,7 +2140,7 @@ SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM Output: t2.c1, t3.c1 Relations: (public.ft1 t2) INNER JOIN (public.ft2 t3) Remote SQL: SELECT r1."C 1", r2."C 1" FROM ("S 1"."T 1" r1 INNER JOIN "S 1"."T 1" r2 ON (((r1."C 1" = r2."C 1")) AND ((r1.c2 = $1::integer)))) -(13 rows) +(14 rows) SELECT t1."C 1" FROM "S 1"."T 1" t1, LATERAL (SELECT DISTINCT t2.c1, t3.c1 FROM ft1 t2, ft2 t3 WHERE t2.c1 = t3.c1 AND t2.c2 = t1.c2) q ORDER BY t1."C 1" OFFSET 10 LIMIT 10; C 1 @@ -2288,7 +2295,8 @@ SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = f Remote SQL: SELECT c1, c2, c3 FROM "S 1"."T 4" FOR UPDATE -> Index Scan using local_tbl_pkey on public.local_tbl Output: local_tbl.c1, local_tbl.c2, local_tbl.c3, local_tbl.ctid -(47 rows) + Skip scan: All +(48 rows) SELECT * FROM ft1, ft2, ft4, ft5, local_tbl WHERE ft1.c1 = ft2.c1 AND ft1.c2 = ft4.c1 AND ft1.c2 = ft5.c1 AND ft1.c2 = local_tbl.c1 AND ft1.c1 < 100 AND ft2.c1 < 100 FOR UPDATE; @@ -3332,6 +3340,7 @@ select c2, sum from "S 1"."T 1" t1, lateral (select sum(t2.c1 + t1."C 1") sum fr Output: t1.c2, qry.sum -> Index Scan using t1_pkey on "S 1"."T 1" t1 Output: t1."C 1", t1.c2, t1.c3, t1.c4, t1.c5, t1.c6, t1.c7, t1.c8 + Skip scan: All Index Cond: (t1."C 1" < 100) Filter: (t1.c2 < 3) -> Subquery Scan on qry @@ -3341,7 +3350,7 @@ select c2, sum from "S 1"."T 1" t1, lateral (select sum(t2.c1 + t1."C 1") sum fr Output: (sum((t2.c1 + t1."C 1"))), t2.c1 Relations: Aggregate on (public.ft2 t2) Remote SQL: SELECT sum(("C 1" + $1::integer)), "C 1" FROM "S 1"."T 1" GROUP BY 2 -(16 rows) +(17 rows) select c2, sum from "S 1"."T 1" t1, lateral (select sum(t2.c1 + t1."C 1") sum from ft2 t2 group by t2.c1) qry where t1.c2 * 2 = qry.sum and t1.c2 < 3 and t1."C 1" < 100 order by 1; c2 | sum @@ -3372,6 +3381,7 @@ ORDER BY ref_0."C 1"; Output: ref_0.c2, ref_0."C 1", ref_1.c3, (ref_0.c2) -> Index Scan using t1_pkey on "S 1"."T 1" ref_0 Output: ref_0."C 1", ref_0.c2, ref_0.c3, ref_0.c4, ref_0.c5, ref_0.c6, ref_0.c7, ref_0.c8 + Skip scan: All Index Cond: (ref_0."C 1" < 10) -> Foreign Scan on public.ft1 ref_1 Output: ref_1.c3, ref_0.c2 @@ -3381,7 +3391,7 @@ ORDER BY ref_0."C 1"; -> Foreign Scan on public.ft2 ref_3 Output: ref_3.c3 Remote SQL: SELECT c3 FROM "S 1"."T 1" WHERE ((c3 = '00001'::text)) -(15 rows) +(16 rows) SELECT ref_0.c2, subq_1.* FROM @@ -4149,11 +4159,12 @@ explain (verbose, costs off) select * from ft3 f, loct3 l Output: f.f1, f.f2, f.f3, l.f1, l.f2, l.f3 -> Index Scan using loct3_f1_key on public.loct3 l Output: l.f1, l.f2, l.f3 + Skip scan: All Index Cond: (l.f1 = 'foo'::text) -> Foreign Scan on public.ft3 f Output: f.f1, f.f2, f.f3 Remote SQL: SELECT f1, f2, f3 FROM public.loct3 WHERE (($1::character varying(10) = f3)) -(8 rows) +(9 rows) -- can't be sent to remote explain (verbose, costs off) select * from ft3 where f1 COLLATE "POSIX" = 'foo'; @@ -4207,8 +4218,9 @@ explain (verbose, costs off) select * from ft3 f, loct3 l Output: l.f1, l.f2, l.f3 -> Index Scan using loct3_f1_key on public.loct3 l Output: l.f1, l.f2, l.f3 + Skip scan: All Index Cond: (l.f1 = 'foo'::text) -(12 rows) +(13 rows) -- =================================================================== -- test writable foreign table stuff @@ -7361,12 +7373,14 @@ explain (verbose, costs off) Sort Key: foo.f1 -> Index Scan using i_foo_f1 on public.foo foo_1 Output: foo_1.f1, foo_1.f2 + Skip scan: All -> Foreign Scan on public.foo2 foo_2 Output: foo_2.f1, foo_2.f2 Remote SQL: SELECT f1, f2 FROM public.loct1 ORDER BY f1 ASC NULLS LAST -> Index Only Scan using i_loct1_f1 on public.loct1 Output: loct1.f1 -(17 rows) + Skip scan: All +(19 rows) select foo.f1, loct1.f1 from foo join loct1 on (foo.f1 = loct1.f1) order by foo.f2 offset 10 limit 10; f1 | f1 @@ -7401,12 +7415,14 @@ explain (verbose, costs off) Sort Key: foo.f1 -> Index Scan using i_foo_f1 on public.foo foo_1 Output: foo_1.f1, foo_1.f2 + Skip scan: All -> Foreign Scan on public.foo2 foo_2 Output: foo_2.f1, foo_2.f2 Remote SQL: SELECT f1, f2 FROM public.loct1 ORDER BY f1 ASC NULLS LAST -> Index Only Scan using i_loct1_f1 on public.loct1 Output: loct1.f1 -(17 rows) + Skip scan: All +(19 rows) select foo.f1, loct1.f1 from foo left join loct1 on (foo.f1 = loct1.f1) order by foo.f2 offset 10 limit 10; f1 | f1 @@ -7447,10 +7463,11 @@ delete from foo where f1 < 5 returning *; Foreign Delete on public.foo2 foo_1 -> Index Scan using i_foo_f1 on public.foo Output: foo.ctid + Skip scan: All Index Cond: (foo.f1 < 5) -> Foreign Delete on public.foo2 foo_1 Remote SQL: DELETE FROM public.loct1 WHERE ((f1 < 5)) RETURNING f1, f2 -(9 rows) +(10 rows) delete from foo where f1 < 5 returning *; f1 | f2 diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 87d39570b5..865c4af8df 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -1029,6 +1029,13 @@ create_index_path(PlannerInfo *root, pathnode->indexorderbycols = indexorderbycols; pathnode->indexscandir = indexscandir; + /* @todo this is just for testing purposes. + * we need a better selection mechanism for when to + * use skip scan and when to use regular index scan + */ + if (!partial_path && index->amcanskip && enable_indexskipscan) + pathnode->indexskipprefix = 10; + cost_index(pathnode, root, loop_count, partial_path); return pathnode; diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 8339f4cd7a..91ae33d74c 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -5929,13 +5929,22 @@ btcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, if (indexcol != iclause->indexcol) { + /* @todo this estimate is wrong but use it for + now for testing purposes. it forces index skip scan to + be used as often as possible. + */ /* Beginning of a new column's quals */ - if (!eqQualHere) + if (!eqQualHere && path->indexskipprefix == 0) break; /* done if no '=' qual for indexcol */ eqQualHere = false; indexcol++; if (indexcol != iclause->indexcol) - break; /* no quals at all for indexcol */ + { + if (path->indexskipprefix == 0) + break; /* no quals at all for indexcol */ + else + continue; + } } /* Examine each indexqual associated with this index clause */ diff --git a/src/test/isolation/expected/drop-index-concurrently-1.out b/src/test/isolation/expected/drop-index-concurrently-1.out index 75dff56bc4..448256db95 100644 --- a/src/test/isolation/expected/drop-index-concurrently-1.out +++ b/src/test/isolation/expected/drop-index-concurrently-1.out @@ -15,6 +15,7 @@ QUERY PLAN Sort Sort Key: id -> Index Scan using test_dc_data on test_dc + Skip scan: All Index Cond: (data = 34) step explains: EXPLAIN (COSTS OFF) EXECUTE getrow_seq; QUERY PLAN diff --git a/src/test/isolation/expected/eval-plan-qual.out b/src/test/isolation/expected/eval-plan-qual.out index 3e55a55c63..751988faff 100644 --- a/src/test/isolation/expected/eval-plan-qual.out +++ b/src/test/isolation/expected/eval-plan-qual.out @@ -837,7 +837,9 @@ LockRows -> Merge Join Merge Cond: (a.id = b.id) -> Index Scan using jointest_id_idx on jointest a + Skip scan: All -> Index Scan using jointest_id_idx on jointest b + Skip scan: All id data id data 1 0 1 0 diff --git a/src/test/regress/expected/aggregates.out b/src/test/regress/expected/aggregates.out index 3259a22516..2194f009fd 100644 --- a/src/test/regress/expected/aggregates.out +++ b/src/test/regress/expected/aggregates.out @@ -720,8 +720,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 IS NOT NULL) -(5 rows) +(6 rows) select min(unique1) from tenk1; min @@ -737,8 +738,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 IS NOT NULL) -(5 rows) +(6 rows) select max(unique1) from tenk1; max @@ -754,8 +756,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: ((unique1 IS NOT NULL) AND (unique1 < 42)) -(5 rows) +(6 rows) select max(unique1) from tenk1 where unique1 < 42; max @@ -771,8 +774,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: ((unique1 IS NOT NULL) AND (unique1 > 42)) -(5 rows) +(6 rows) select max(unique1) from tenk1 where unique1 > 42; max @@ -794,8 +798,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: ((unique1 IS NOT NULL) AND (unique1 > 42000)) -(5 rows) +(6 rows) select max(unique1) from tenk1 where unique1 > 42000; max @@ -813,8 +818,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: ((thousand = 33) AND (tenthous IS NOT NULL)) -(5 rows) +(6 rows) select max(tenthous) from tenk1 where thousand = 33; max @@ -830,8 +836,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: ((thousand = 33) AND (tenthous IS NOT NULL)) -(5 rows) +(6 rows) select min(tenthous) from tenk1 where thousand = 33; min @@ -851,8 +858,9 @@ explain (costs off) InitPlan 1 (returns $1) -> Limit -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: ((unique1 IS NOT NULL) AND (unique1 > int4_tbl.f1)) -(7 rows) +(8 rows) select f1, (select min(unique1) from tenk1 where unique1 > f1) AS gt from int4_tbl; @@ -875,9 +883,10 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique2 on tenk1 + Skip scan: All Index Cond: (unique2 IS NOT NULL) -> Result -(7 rows) +(8 rows) select distinct max(unique2) from tenk1; max @@ -894,9 +903,10 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique2 on tenk1 + Skip scan: All Index Cond: (unique2 IS NOT NULL) -> Result -(7 rows) +(8 rows) select max(unique2) from tenk1 order by 1; max @@ -913,9 +923,10 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique2 on tenk1 + Skip scan: All Index Cond: (unique2 IS NOT NULL) -> Result -(7 rows) +(8 rows) select max(unique2) from tenk1 order by max(unique2); max @@ -932,9 +943,10 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique2 on tenk1 + Skip scan: All Index Cond: (unique2 IS NOT NULL) -> Result -(7 rows) +(8 rows) select max(unique2) from tenk1 order by max(unique2)+1; max @@ -951,10 +963,11 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan Backward using tenk1_unique2 on tenk1 + Skip scan: All Index Cond: (unique2 IS NOT NULL) -> ProjectSet -> Result -(8 rows) +(9 rows) select max(unique2), generate_series(1,3) as g from tenk1 order by g desc; max | g @@ -1006,24 +1019,32 @@ explain (costs off) -> Merge Append Sort Key: minmaxtest.f1 -> Index Only Scan using minmaxtesti on minmaxtest minmaxtest_1 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan using minmaxtest1i on minmaxtest1 minmaxtest_2 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 minmaxtest_3 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan using minmaxtest3i on minmaxtest3 minmaxtest_4 + Skip scan: All InitPlan 2 (returns $1) -> Limit -> Merge Append Sort Key: minmaxtest_5.f1 DESC -> Index Only Scan Backward using minmaxtesti on minmaxtest minmaxtest_6 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest_7 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest_8 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest_9 -(23 rows) + Skip scan: All +(31 rows) select min(f1), max(f1) from minmaxtest; min | max @@ -1042,27 +1063,35 @@ explain (costs off) -> Merge Append Sort Key: minmaxtest.f1 -> Index Only Scan using minmaxtesti on minmaxtest minmaxtest_1 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan using minmaxtest1i on minmaxtest1 minmaxtest_2 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan Backward using minmaxtest2i on minmaxtest2 minmaxtest_3 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan using minmaxtest3i on minmaxtest3 minmaxtest_4 + Skip scan: All InitPlan 2 (returns $1) -> Limit -> Merge Append Sort Key: minmaxtest_5.f1 DESC -> Index Only Scan Backward using minmaxtesti on minmaxtest minmaxtest_6 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan Backward using minmaxtest1i on minmaxtest1 minmaxtest_7 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan using minmaxtest2i on minmaxtest2 minmaxtest_8 + Skip scan: All Index Cond: (f1 IS NOT NULL) -> Index Only Scan Backward using minmaxtest3i on minmaxtest3 minmaxtest_9 + Skip scan: All -> Sort Sort Key: ($0), ($1) -> Result -(26 rows) +(34 rows) select distinct min(f1), max(f1) from minmaxtest; min | max diff --git a/src/test/regress/expected/btree_index.out b/src/test/regress/expected/btree_index.out index 1646deb092..7e09e1df8c 100644 --- a/src/test/regress/expected/btree_index.out +++ b/src/test/regress/expected/btree_index.out @@ -110,9 +110,10 @@ select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1; QUERY PLAN ------------------------------------------------------------------------------ Index Only Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= 'RI_FKey'::text) AND (proname < 'RI_FKez'::text)) Filter: (proname ~~ 'RI\_FKey%del'::text) -(3 rows) +(4 rows) select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1; proname @@ -129,9 +130,10 @@ select proname from pg_proc where proname ilike '00%foo' order by 1; QUERY PLAN -------------------------------------------------------------------- Index Only Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= '00'::text) AND (proname < '01'::text)) Filter: (proname ~~* '00%foo'::text) -(3 rows) +(4 rows) select proname from pg_proc where proname ilike '00%foo' order by 1; proname @@ -143,8 +145,9 @@ select proname from pg_proc where proname ilike 'ri%foo' order by 1; QUERY PLAN ----------------------------------------------------------------- Index Only Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Filter: (proname ~~* 'ri%foo'::text) -(2 rows) +(3 rows) set enable_indexscan to false; set enable_bitmapscan to true; @@ -157,8 +160,9 @@ select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1; -> Bitmap Heap Scan on pg_proc Filter: (proname ~~ 'RI\_FKey%del'::text) -> Bitmap Index Scan on pg_proc_proname_args_nsp_index + Skip scan: All Index Cond: ((proname >= 'RI_FKey'::text) AND (proname < 'RI_FKez'::text)) -(6 rows) +(7 rows) select proname from pg_proc where proname like E'RI\\_FKey%del' order by 1; proname @@ -179,8 +183,9 @@ select proname from pg_proc where proname ilike '00%foo' order by 1; -> Bitmap Heap Scan on pg_proc Filter: (proname ~~* '00%foo'::text) -> Bitmap Index Scan on pg_proc_proname_args_nsp_index + Skip scan: All Index Cond: ((proname >= '00'::text) AND (proname < '01'::text)) -(6 rows) +(7 rows) select proname from pg_proc where proname ilike '00%foo' order by 1; proname @@ -192,8 +197,9 @@ select proname from pg_proc where proname ilike 'ri%foo' order by 1; QUERY PLAN ----------------------------------------------------------------- Index Only Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Filter: (proname ~~* 'ri%foo'::text) -(2 rows) +(3 rows) reset enable_seqscan; reset enable_indexscan; @@ -240,8 +246,9 @@ select * from btree_bpchar where f1::bpchar like 'foo'; Bitmap Heap Scan on btree_bpchar Filter: ((f1)::bpchar ~~ 'foo'::text) -> Bitmap Index Scan on btree_bpchar_f1_idx + Skip scan: All Index Cond: ((f1)::bpchar = 'foo'::bpchar) -(4 rows) +(5 rows) select * from btree_bpchar where f1::bpchar like 'foo'; f1 @@ -256,8 +263,9 @@ select * from btree_bpchar where f1::bpchar like 'foo%'; Bitmap Heap Scan on btree_bpchar Filter: ((f1)::bpchar ~~ 'foo%'::text) -> Bitmap Index Scan on btree_bpchar_f1_idx + Skip scan: All Index Cond: (((f1)::bpchar >= 'foo'::bpchar) AND ((f1)::bpchar < 'fop'::bpchar)) -(4 rows) +(5 rows) select * from btree_bpchar where f1::bpchar like 'foo%'; f1 diff --git a/src/test/regress/expected/cluster.out b/src/test/regress/expected/cluster.out index bdae8fe00c..e7eeebf7e1 100644 --- a/src/test/regress/expected/cluster.out +++ b/src/test/regress/expected/cluster.out @@ -478,8 +478,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'; QUERY PLAN --------------------------------------------------------------- Index Scan using clstr_expression_upper_b on clstr_expression + Skip scan: All Index Cond: (upper(b) = 'PREFIX3'::text) -(2 rows) +(3 rows) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'; id | a | b @@ -491,8 +492,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; QUERY PLAN --------------------------------------------------------------- Index Scan using clstr_expression_minus_a on clstr_expression + Skip scan: All Index Cond: ((- a) = '-3'::integer) -(2 rows) +(3 rows) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; id | a | b @@ -512,8 +514,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'; QUERY PLAN --------------------------------------------------------------- Index Scan using clstr_expression_upper_b on clstr_expression + Skip scan: All Index Cond: (upper(b) = 'PREFIX3'::text) -(2 rows) +(3 rows) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'; id | a | b @@ -525,8 +528,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; QUERY PLAN --------------------------------------------------------------- Index Scan using clstr_expression_minus_a on clstr_expression + Skip scan: All Index Cond: ((- a) = '-3'::integer) -(2 rows) +(3 rows) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; id | a | b @@ -546,8 +550,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'; QUERY PLAN --------------------------------------------------------------- Index Scan using clstr_expression_upper_b on clstr_expression + Skip scan: All Index Cond: (upper(b) = 'PREFIX3'::text) -(2 rows) +(3 rows) SELECT * FROM clstr_expression WHERE upper(b) = 'PREFIX3'; id | a | b @@ -559,8 +564,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; QUERY PLAN --------------------------------------------------------------- Index Scan using clstr_expression_minus_a on clstr_expression + Skip scan: All Index Cond: ((- a) = '-3'::integer) -(2 rows) +(3 rows) SELECT * FROM clstr_expression WHERE -a = -3 ORDER BY -a, b; id | a | b diff --git a/src/test/regress/expected/create_index.out b/src/test/regress/expected/create_index.out index ae95bb38a6..f8132ecacd 100644 --- a/src/test/regress/expected/create_index.out +++ b/src/test/regress/expected/create_index.out @@ -1804,12 +1804,15 @@ SELECT * FROM tenk1 Recheck Cond: (((thousand = 42) AND (tenthous = 1)) OR ((thousand = 42) AND (tenthous = 3)) OR ((thousand = 42) AND (tenthous = 42))) -> BitmapOr -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: ((thousand = 42) AND (tenthous = 1)) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: ((thousand = 42) AND (tenthous = 3)) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: ((thousand = 42) AND (tenthous = 42)) -(9 rows) +(12 rows) SELECT * FROM tenk1 WHERE thousand = 42 AND (tenthous = 1 OR tenthous = 3 OR tenthous = 42); @@ -1828,13 +1831,16 @@ SELECT count(*) FROM tenk1 Recheck Cond: ((hundred = 42) AND ((thousand = 42) OR (thousand = 99))) -> BitmapAnd -> Bitmap Index Scan on tenk1_hundred + Skip scan: All Index Cond: (hundred = 42) -> BitmapOr -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = 42) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = 99) -(11 rows) +(14 rows) SELECT count(*) FROM tenk1 WHERE hundred = 42 AND (thousand = 42 OR thousand = 99); @@ -1859,8 +1865,9 @@ EXPLAIN (COSTS OFF) -> Bitmap Heap Scan on dupindexcols Recheck Cond: ((f1 >= 'WA'::text) AND (f1 <= 'ZZZ'::text) AND (id < 1000) AND (f1 ~<~ 'YX'::text)) -> Bitmap Index Scan on dupindexcols_i + Skip scan: All Index Cond: ((f1 >= 'WA'::text) AND (f1 <= 'ZZZ'::text) AND (id < 1000) AND (f1 ~<~ 'YX'::text)) -(5 rows) +(6 rows) SELECT count(*) FROM dupindexcols WHERE f1 BETWEEN 'WA' AND 'ZZZ' and id < 1000 and f1 ~<~ 'YX'; @@ -1880,8 +1887,9 @@ ORDER BY unique1; QUERY PLAN ------------------------------------------------------- Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = ANY ('{1,42,7}'::integer[])) -(2 rows) +(3 rows) SELECT unique1 FROM tenk1 WHERE unique1 IN (1,42,7) @@ -1900,9 +1908,10 @@ ORDER BY thousand; QUERY PLAN ------------------------------------------------------- Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: (thousand < 2) Filter: (tenthous = ANY ('{1001,3000}'::integer[])) -(3 rows) +(4 rows) SELECT thousand, tenthous FROM tenk1 WHERE thousand < 2 AND tenthous IN (1001,3000) @@ -1923,8 +1932,9 @@ ORDER BY thousand; Sort Sort Key: thousand -> Index Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: ((thousand < 2) AND (tenthous = ANY ('{1001,3000}'::integer[]))) -(4 rows) +(5 rows) SELECT thousand, tenthous FROM tenk1 WHERE thousand < 2 AND tenthous IN (1001,3000) @@ -1944,8 +1954,9 @@ explain (costs off) QUERY PLAN ------------------------------------------------------ Index Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: ((thousand = 1) AND (tenthous = 1001)) -(2 rows) +(3 rows) -- -- Check matching of boolean index columns to WHERE conditions and sort keys @@ -1957,7 +1968,8 @@ explain (costs off) ------------------------------------------------------- Limit -> Index Scan using boolindex_b_i_key on boolindex -(2 rows) + Skip scan: All +(3 rows) explain (costs off) select * from boolindex where b order by i limit 10; @@ -1965,8 +1977,9 @@ explain (costs off) ------------------------------------------------------- Limit -> Index Scan using boolindex_b_i_key on boolindex + Skip scan: All Index Cond: (b = true) -(3 rows) +(4 rows) explain (costs off) select * from boolindex where b = true order by i desc limit 10; @@ -1974,8 +1987,9 @@ explain (costs off) ---------------------------------------------------------------- Limit -> Index Scan Backward using boolindex_b_i_key on boolindex + Skip scan: All Index Cond: (b = true) -(3 rows) +(4 rows) explain (costs off) select * from boolindex where not b order by i limit 10; @@ -1983,8 +1997,9 @@ explain (costs off) ------------------------------------------------------- Limit -> Index Scan using boolindex_b_i_key on boolindex + Skip scan: All Index Cond: (b = false) -(3 rows) +(4 rows) explain (costs off) select * from boolindex where b is true order by i desc limit 10; @@ -1992,8 +2007,9 @@ explain (costs off) ---------------------------------------------------------------- Limit -> Index Scan Backward using boolindex_b_i_key on boolindex + Skip scan: All Index Cond: (b = true) -(3 rows) +(4 rows) explain (costs off) select * from boolindex where b is false order by i desc limit 10; @@ -2001,8 +2017,9 @@ explain (costs off) ---------------------------------------------------------------- Limit -> Index Scan Backward using boolindex_b_i_key on boolindex + Skip scan: All Index Cond: (b = false) -(3 rows) +(4 rows) -- -- REINDEX (VERBOSE) diff --git a/src/test/regress/expected/equivclass.out b/src/test/regress/expected/equivclass.out index 126f7047fe..e163b8bf89 100644 --- a/src/test/regress/expected/equivclass.out +++ b/src/test/regress/expected/equivclass.out @@ -107,27 +107,30 @@ explain (costs off) QUERY PLAN ----------------------------------- Index Scan using ec0_pkey on ec0 + Skip scan: All Index Cond: (ff = '42'::bigint) Filter: (f1 = '42'::bigint) -(3 rows) +(4 rows) explain (costs off) select * from ec0 where ff = f1 and f1 = '42'::int8alias1; QUERY PLAN --------------------------------------- Index Scan using ec0_pkey on ec0 + Skip scan: All Index Cond: (ff = '42'::int8alias1) Filter: (f1 = '42'::int8alias1) -(3 rows) +(4 rows) explain (costs off) select * from ec1 where ff = f1 and f1 = '42'::int8alias1; QUERY PLAN --------------------------------------- Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::int8alias1) Filter: (f1 = '42'::int8alias1) -(3 rows) +(4 rows) explain (costs off) select * from ec1 where ff = f1 and f1 = '42'::int8alias2; @@ -144,9 +147,10 @@ explain (costs off) Nested Loop Join Filter: (ec1.ff = ec2.x1) -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: ((ff = '42'::bigint) AND (ff = '42'::bigint)) -> Seq Scan on ec2 -(5 rows) +(6 rows) explain (costs off) select * from ec1, ec2 where ff = x1 and ff = '42'::int8alias1; @@ -154,10 +158,11 @@ explain (costs off) --------------------------------------------- Nested Loop -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::int8alias1) -> Seq Scan on ec2 Filter: (x1 = '42'::int8alias1) -(5 rows) +(6 rows) explain (costs off) select * from ec1, ec2 where ff = x1 and '42'::int8 = x1; @@ -166,10 +171,11 @@ explain (costs off) Nested Loop Join Filter: (ec1.ff = ec2.x1) -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::bigint) -> Seq Scan on ec2 Filter: ('42'::bigint = x1) -(6 rows) +(7 rows) explain (costs off) select * from ec1, ec2 where ff = x1 and x1 = '42'::int8alias1; @@ -177,10 +183,11 @@ explain (costs off) --------------------------------------------- Nested Loop -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::int8alias1) -> Seq Scan on ec2 Filter: (x1 = '42'::int8alias1) -(5 rows) +(6 rows) explain (costs off) select * from ec1, ec2 where ff = x1 and x1 = '42'::int8alias2; @@ -190,8 +197,9 @@ explain (costs off) -> Seq Scan on ec2 Filter: (x1 = '42'::int8alias2) -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = ec2.x1) -(5 rows) +(6 rows) create unique index ec1_expr1 on ec1((ff + 1)); create unique index ec1_expr2 on ec1((ff + 2 + 1)); @@ -210,15 +218,19 @@ explain (costs off) ----------------------------------------------------- Nested Loop -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::bigint) -> Append -> Index Scan using ec1_expr2 on ec1 ec1_1 + Skip scan: All Index Cond: (((ff + 2) + 1) = ec1.f1) -> Index Scan using ec1_expr3 on ec1 ec1_2 + Skip scan: All Index Cond: (((ff + 3) + 1) = ec1.f1) -> Index Scan using ec1_expr4 on ec1 ec1_3 + Skip scan: All Index Cond: ((ff + 4) = ec1.f1) -(10 rows) +(14 rows) explain (costs off) select * from ec1, @@ -234,16 +246,20 @@ explain (costs off) Nested Loop Join Filter: ((((ec1_1.ff + 2) + 1)) = ec1.f1) -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: ((ff = '42'::bigint) AND (ff = '42'::bigint)) Filter: (ff = f1) -> Append -> Index Scan using ec1_expr2 on ec1 ec1_1 + Skip scan: All Index Cond: (((ff + 2) + 1) = '42'::bigint) -> Index Scan using ec1_expr3 on ec1 ec1_2 + Skip scan: All Index Cond: (((ff + 3) + 1) = '42'::bigint) -> Index Scan using ec1_expr4 on ec1 ec1_3 + Skip scan: All Index Cond: ((ff + 4) = '42'::bigint) -(12 rows) +(16 rows) explain (costs off) select * from ec1, @@ -265,22 +281,29 @@ explain (costs off) Nested Loop -> Nested Loop -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::bigint) -> Append -> Index Scan using ec1_expr2 on ec1 ec1_1 + Skip scan: All Index Cond: (((ff + 2) + 1) = ec1.f1) -> Index Scan using ec1_expr3 on ec1 ec1_2 + Skip scan: All Index Cond: (((ff + 3) + 1) = ec1.f1) -> Index Scan using ec1_expr4 on ec1 ec1_3 + Skip scan: All Index Cond: ((ff + 4) = ec1.f1) -> Append -> Index Scan using ec1_expr2 on ec1 ec1_4 + Skip scan: All Index Cond: (((ff + 2) + 1) = (((ec1_1.ff + 2) + 1))) -> Index Scan using ec1_expr3 on ec1 ec1_5 + Skip scan: All Index Cond: (((ff + 3) + 1) = (((ec1_1.ff + 2) + 1))) -> Index Scan using ec1_expr4 on ec1 ec1_6 + Skip scan: All Index Cond: ((ff + 4) = (((ec1_1.ff + 2) + 1))) -(18 rows) +(25 rows) -- let's try that as a mergejoin set enable_mergejoin = on; @@ -307,21 +330,28 @@ explain (costs off) -> Merge Append Sort Key: (((ec1_4.ff + 2) + 1)) -> Index Scan using ec1_expr2 on ec1 ec1_4 + Skip scan: All -> Index Scan using ec1_expr3 on ec1 ec1_5 + Skip scan: All -> Index Scan using ec1_expr4 on ec1 ec1_6 + Skip scan: All -> Materialize -> Merge Join Merge Cond: ((((ec1_1.ff + 2) + 1)) = ec1.f1) -> Merge Append Sort Key: (((ec1_1.ff + 2) + 1)) -> Index Scan using ec1_expr2 on ec1 ec1_1 + Skip scan: All -> Index Scan using ec1_expr3 on ec1 ec1_2 + Skip scan: All -> Index Scan using ec1_expr4 on ec1 ec1_3 + Skip scan: All -> Sort Sort Key: ec1.f1 USING < -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::bigint) -(19 rows) +(26 rows) -- check partially indexed scan set enable_nestloop = on; @@ -340,15 +370,18 @@ explain (costs off) ----------------------------------------------------- Nested Loop -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::bigint) -> Append -> Index Scan using ec1_expr2 on ec1 ec1_1 + Skip scan: All Index Cond: (((ff + 2) + 1) = ec1.f1) -> Seq Scan on ec1 ec1_2 Filter: (((ff + 3) + 1) = ec1.f1) -> Index Scan using ec1_expr4 on ec1 ec1_3 + Skip scan: All Index Cond: ((ff + 4) = ec1.f1) -(10 rows) +(13 rows) -- let's try that as a mergejoin set enable_mergejoin = on; @@ -369,15 +402,18 @@ explain (costs off) -> Merge Append Sort Key: (((ec1_1.ff + 2) + 1)) -> Index Scan using ec1_expr2 on ec1 ec1_1 + Skip scan: All -> Sort Sort Key: (((ec1_2.ff + 3) + 1)) -> Seq Scan on ec1 ec1_2 -> Index Scan using ec1_expr4 on ec1 ec1_3 + Skip scan: All -> Sort Sort Key: ec1.f1 USING < -> Index Scan using ec1_pkey on ec1 + Skip scan: All Index Cond: (ff = '42'::bigint) -(13 rows) +(16 rows) -- check effects of row-level security set enable_nestloop = on; @@ -395,10 +431,12 @@ explain (costs off) --------------------------------------------- Nested Loop -> Index Scan using ec0_pkey on ec0 a + Skip scan: All Index Cond: (ff = '43'::int8alias1) -> Index Scan using ec1_pkey on ec1 b + Skip scan: All Index Cond: (ff = '43'::int8alias1) -(5 rows) +(7 rows) set session authorization regress_user_ectest; -- with RLS active, the non-leakproof a.ff = 43 clause is not treated @@ -411,11 +449,13 @@ explain (costs off) --------------------------------------------- Nested Loop -> Index Scan using ec0_pkey on ec0 a + Skip scan: All Index Cond: (ff = '43'::int8alias1) -> Index Scan using ec1_pkey on ec1 b + Skip scan: All Index Cond: (ff = a.ff) Filter: (f1 < '5'::int8alias1) -(6 rows) +(8 rows) reset session authorization; revoke select on ec0 from regress_user_ectest; diff --git a/src/test/regress/expected/fast_default.out b/src/test/regress/expected/fast_default.out index 10bc5ff757..145145b71c 100644 --- a/src/test/regress/expected/fast_default.out +++ b/src/test/regress/expected/fast_default.out @@ -431,8 +431,9 @@ DELETE FROM T WHERE pk BETWEEN 10 AND 20 RETURNING *; Output: ctid Recheck Cond: ((t.pk >= 10) AND (t.pk <= 20)) -> Bitmap Index Scan on t_pkey + Skip scan: All Index Cond: ((t.pk >= 10) AND (t.pk <= 20)) -(7 rows) +(8 rows) -- UPDATE UPDATE T SET c_text = '"' || c_text || '"' WHERE pk < 10; diff --git a/src/test/regress/expected/foreign_key.out b/src/test/regress/expected/foreign_key.out index 07bd5b6434..d9f5d6bfbe 100644 --- a/src/test/regress/expected/foreign_key.out +++ b/src/test/regress/expected/foreign_key.out @@ -1418,14 +1418,16 @@ explain (costs off) delete from t1 where a = 1; Delete on t2 -> Nested Loop -> Index Scan using t1_pkey on t1 + Skip scan: All Index Cond: (a = 1) -> Seq Scan on t2 Filter: (b = 1) Delete on t1 -> Index Scan using t1_pkey on t1 + Skip scan: All Index Cond: (a = 1) -(10 rows) +(12 rows) delete from t1 where a = 1; -- Test a primary key with attributes located in later attnum positions diff --git a/src/test/regress/expected/generated.out b/src/test/regress/expected/generated.out index 620579a6fd..61b267f9aa 100644 --- a/src/test/regress/expected/generated.out +++ b/src/test/regress/expected/generated.out @@ -462,8 +462,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM gtest22c WHERE b = 4; QUERY PLAN --------------------------------------------- Index Scan using gtest22c_b_idx on gtest22c + Skip scan: All Index Cond: (b = 4) -(2 rows) +(3 rows) SELECT * FROM gtest22c WHERE b = 4; a | b @@ -475,8 +476,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM gtest22c WHERE b * 3 = 6; QUERY PLAN ------------------------------------------------ Index Scan using gtest22c_expr_idx on gtest22c + Skip scan: All Index Cond: ((b * 3) = 6) -(2 rows) +(3 rows) SELECT * FROM gtest22c WHERE b * 3 = 6; a | b @@ -488,8 +490,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM gtest22c WHERE a = 1 AND b > 0; QUERY PLAN ------------------------------------------------ Index Scan using gtest22c_pred_idx on gtest22c + Skip scan: All Index Cond: (a = 1) -(2 rows) +(3 rows) SELECT * FROM gtest22c WHERE a = 1 AND b > 0; a | b diff --git a/src/test/regress/expected/groupingsets.out b/src/test/regress/expected/groupingsets.out index dbe5140b55..164451558c 100644 --- a/src/test/regress/expected/groupingsets.out +++ b/src/test/regress/expected/groupingsets.out @@ -466,8 +466,9 @@ explain (costs off) InitPlan 1 (returns $0) -> Limit -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 IS NOT NULL) -(5 rows) +(6 rows) -- Views with GROUPING SET queries CREATE VIEW gstest_view AS select a, b, grouping(a,b), sum(c), count(*), max(c) @@ -1402,7 +1403,8 @@ EXPLAIN (COSTS OFF) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY Sort Key: b Group Key: b -> Index Scan using gstest3_pkey on gstest3 -(8 rows) + Skip scan: All +(9 rows) SELECT a, b, count(*), max(a), max(b) FROM gstest3 GROUP BY GROUPING SETS(a, b,()) ORDER BY a, b; a | b | count | max | max diff --git a/src/test/regress/expected/index_including.out b/src/test/regress/expected/index_including.out index 8e5d53e712..4db90623f9 100644 --- a/src/test/regress/expected/index_including.out +++ b/src/test/regress/expected/index_including.out @@ -134,8 +134,9 @@ select * from tbl where (c1,c2,c3) < (2,5,1); Bitmap Heap Scan on tbl Filter: (ROW(c1, c2, c3) < ROW(2, 5, 1)) -> Bitmap Index Scan on covering + Skip scan: All Index Cond: (ROW(c1, c2) <= ROW(2, 5)) -(4 rows) +(5 rows) select * from tbl where (c1,c2,c3) < (2,5,1); c1 | c2 | c3 | c4 @@ -152,9 +153,10 @@ select * from tbl where (c1,c2,c3) < (262,1,1) limit 1; ---------------------------------------------------- Limit -> Index Only Scan using covering on tbl + Skip scan: All Index Cond: (ROW(c1, c2) <= ROW(262, 1)) Filter: (ROW(c1, c2, c3) < ROW(262, 1, 1)) -(4 rows) +(5 rows) select * from tbl where (c1,c2,c3) < (262,1,1) limit 1; c1 | c2 | c3 | c4 diff --git a/src/test/regress/expected/inet.out b/src/test/regress/expected/inet.out index 12df25fe9d..3d1fd73fd6 100644 --- a/src/test/regress/expected/inet.out +++ b/src/test/regress/expected/inet.out @@ -247,9 +247,10 @@ SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr; QUERY PLAN ------------------------------------------------------------------------------- Index Scan using inet_idx1 on inet_tbl + Skip scan: All Index Cond: ((i > '192.168.1.0/24'::inet) AND (i <= '192.168.1.255'::inet)) Filter: (i << '192.168.1.0/24'::inet) -(3 rows) +(4 rows) SELECT * FROM inet_tbl WHERE i<<'192.168.1.0/24'::cidr; c | i @@ -264,9 +265,10 @@ SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr; QUERY PLAN -------------------------------------------------------------------------------- Index Scan using inet_idx1 on inet_tbl + Skip scan: All Index Cond: ((i >= '192.168.1.0/24'::inet) AND (i <= '192.168.1.255'::inet)) Filter: (i <<= '192.168.1.0/24'::inet) -(3 rows) +(4 rows) SELECT * FROM inet_tbl WHERE i<<='192.168.1.0/24'::cidr; c | i @@ -284,9 +286,10 @@ SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i; QUERY PLAN -------------------------------------------------------------------------------- Index Scan using inet_idx1 on inet_tbl + Skip scan: All Index Cond: ((i >= '192.168.1.0/24'::inet) AND (i <= '192.168.1.255'::inet)) Filter: ('192.168.1.0/24'::inet >>= i) -(3 rows) +(4 rows) SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >>= i; c | i @@ -304,9 +307,10 @@ SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i; QUERY PLAN ------------------------------------------------------------------------------- Index Scan using inet_idx1 on inet_tbl + Skip scan: All Index Cond: ((i > '192.168.1.0/24'::inet) AND (i <= '192.168.1.255'::inet)) Filter: ('192.168.1.0/24'::inet >> i) -(3 rows) +(4 rows) SELECT * FROM inet_tbl WHERE '192.168.1.0/24'::cidr >> i; c | i diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index dfd0ee414f..2f0be34a15 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -1339,12 +1339,15 @@ select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; -> Seq Scan on int4_tbl -> Append -> Index Scan using patest0i on patest0 patest0_1 + Skip scan: All Index Cond: (id = int4_tbl.f1) -> Index Scan using patest1i on patest1 patest0_2 + Skip scan: All Index Cond: (id = int4_tbl.f1) -> Index Scan using patest2i on patest2 patest0_3 + Skip scan: All Index Cond: (id = int4_tbl.f1) -(10 rows) +(13 rows) select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; id | x | f1 @@ -1364,12 +1367,14 @@ select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; -> Seq Scan on int4_tbl -> Append -> Index Scan using patest0i on patest0 patest0_1 + Skip scan: All Index Cond: (id = int4_tbl.f1) -> Index Scan using patest1i on patest1 patest0_2 + Skip scan: All Index Cond: (id = int4_tbl.f1) -> Seq Scan on patest2 patest0_3 Filter: (int4_tbl.f1 = id) -(10 rows) +(12 rows) select * from patest0 join (select f1 from int4_tbl limit 1) ss on id = f1; id | x | f1 @@ -1466,8 +1471,10 @@ explain (verbose, costs off) select * from matest0 order by 1-id; Sort Key: ((1 - matest0.id)) -> Index Scan using matest0i on public.matest0 matest0_1 Output: matest0_1.id, matest0_1.name, (1 - matest0_1.id) + Skip scan: All -> Index Scan using matest1i on public.matest1 matest0_2 Output: matest0_2.id, matest0_2.name, (1 - matest0_2.id) + Skip scan: All -> Sort Output: matest0_3.id, matest0_3.name, ((1 - matest0_3.id)) Sort Key: ((1 - matest0_3.id)) @@ -1475,7 +1482,8 @@ explain (verbose, costs off) select * from matest0 order by 1-id; Output: matest0_3.id, matest0_3.name, (1 - matest0_3.id) -> Index Scan using matest3i on public.matest3 matest0_4 Output: matest0_4.id, matest0_4.name, (1 - matest0_4.id) -(13 rows) + Skip scan: All +(16 rows) select * from matest0 order by 1-id; id | name @@ -1502,9 +1510,11 @@ explain (verbose, costs off) select min(1-id) from matest0; Sort Key: ((1 - matest0.id)) -> Index Scan using matest0i on public.matest0 matest0_1 Output: matest0_1.id, (1 - matest0_1.id) + Skip scan: All Index Cond: ((1 - matest0_1.id) IS NOT NULL) -> Index Scan using matest1i on public.matest1 matest0_2 Output: matest0_2.id, (1 - matest0_2.id) + Skip scan: All Index Cond: ((1 - matest0_2.id) IS NOT NULL) -> Sort Output: matest0_3.id, ((1 - matest0_3.id)) @@ -1513,10 +1523,12 @@ explain (verbose, costs off) select min(1-id) from matest0; Output: matest0_3.id, (1 - matest0_3.id) Filter: ((1 - matest0_3.id) IS NOT NULL) -> Bitmap Index Scan on matest2_pkey + Skip scan: All -> Index Scan using matest3i on public.matest3 matest0_4 Output: matest0_4.id, (1 - matest0_4.id) + Skip scan: All Index Cond: ((1 - matest0_4.id) IS NOT NULL) -(25 rows) +(29 rows) select min(1-id) from matest0; min @@ -1552,15 +1564,19 @@ order by t1.b limit 10; -> Merge Append Sort Key: t1.b -> Index Scan using matest0i on matest0 t1_1 + Skip scan: All -> Index Scan using matest1i on matest1 t1_2 + Skip scan: All -> Materialize -> Merge Append Sort Key: t2.b -> Index Scan using matest0i on matest0 t2_1 + Skip scan: All Filter: (c = d) -> Index Scan using matest1i on matest1 t2_2 + Skip scan: All Filter: (c = d) -(14 rows) +(18 rows) reset enable_nestloop; drop table matest0 cascade; @@ -1582,10 +1598,12 @@ ORDER BY thousand, tenthous; Merge Append Sort Key: tenk1.thousand, tenk1.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All -> Sort Sort Key: tenk1_1.thousand, tenk1_1.thousand -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1 -(6 rows) + Skip scan: All +(8 rows) explain (costs off) SELECT thousand, tenthous, thousand+tenthous AS x FROM tenk1 @@ -1597,10 +1615,12 @@ ORDER BY thousand, tenthous; Merge Append Sort Key: tenk1.thousand, tenk1.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All -> Sort Sort Key: 42, 42 -> Index Only Scan using tenk1_hundred on tenk1 tenk1_1 -(6 rows) + Skip scan: All +(8 rows) explain (costs off) SELECT thousand, tenthous FROM tenk1 @@ -1612,10 +1632,12 @@ ORDER BY thousand, tenthous; Merge Append Sort Key: tenk1.thousand, tenk1.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All -> Sort Sort Key: tenk1_1.thousand, ((random())::integer) -> Index Only Scan using tenk1_thous_tenthous on tenk1 tenk1_1 -(6 rows) + Skip scan: All +(8 rows) -- Check min/max aggregate optimization explain (costs off) @@ -1631,10 +1653,12 @@ SELECT min(x) FROM -> Merge Append Sort Key: a.unique1 -> Index Only Scan using tenk1_unique1 on tenk1 a + Skip scan: All Index Cond: (unique1 IS NOT NULL) -> Index Only Scan using tenk1_unique2 on tenk1 b + Skip scan: All Index Cond: (unique2 IS NOT NULL) -(9 rows) +(11 rows) explain (costs off) SELECT min(y) FROM @@ -1649,10 +1673,12 @@ SELECT min(y) FROM -> Merge Append Sort Key: a.unique1 -> Index Only Scan using tenk1_unique1 on tenk1 a + Skip scan: All Index Cond: (unique1 IS NOT NULL) -> Index Only Scan using tenk1_unique2 on tenk1 b + Skip scan: All Index Cond: (unique2 IS NOT NULL) -(9 rows) +(11 rows) -- XXX planner doesn't recognize that index on unique2 is sufficiently sorted explain (costs off) @@ -1666,10 +1692,12 @@ ORDER BY x, y; Merge Append Sort Key: a.thousand, a.tenthous -> Index Only Scan using tenk1_thous_tenthous on tenk1 a + Skip scan: All -> Sort Sort Key: b.unique2, b.unique2 -> Index Only Scan using tenk1_unique2 on tenk1 b -(6 rows) + Skip scan: All +(8 rows) -- exercise rescan code path via a repeatedly-evaluated subquery explain (costs off) @@ -2069,12 +2097,14 @@ explain (costs off) select min(a), max(a) from parted_minmax where b = '12345'; InitPlan 1 (returns $0) -> Limit -> Index Only Scan using parted_minmax1i on parted_minmax1 parted_minmax + Skip scan: All Index Cond: ((a IS NOT NULL) AND (b = '12345'::text)) InitPlan 2 (returns $1) -> Limit -> Index Only Scan Backward using parted_minmax1i on parted_minmax1 parted_minmax_1 + Skip scan: All Index Cond: ((a IS NOT NULL) AND (b = '12345'::text)) -(9 rows) +(11 rows) select min(a), max(a) from parted_minmax where b = '12345'; min | max @@ -2093,13 +2123,20 @@ explain (costs off) select * from mcrparted order by a, abs(b), c; Merge Append Sort Key: mcrparted.a, (abs(mcrparted.b)), mcrparted.c -> Index Scan using mcrparted0_a_abs_c_idx on mcrparted0 mcrparted_1 + Skip scan: All -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All -> Index Scan using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All -> Index Scan using mcrparted4_a_abs_c_idx on mcrparted4 mcrparted_5 + Skip scan: All -> Index Scan using mcrparted5_a_abs_c_idx on mcrparted5 mcrparted_6 + Skip scan: All -> Index Scan using mcrparted_def_a_abs_c_idx on mcrparted_def mcrparted_7 -(9 rows) + Skip scan: All +(16 rows) drop table mcrparted_def; -- Append is used for a RANGE partitioned table with no default @@ -2109,12 +2146,18 @@ explain (costs off) select * from mcrparted order by a, abs(b), c; ------------------------------------------------------------------------- Append -> Index Scan using mcrparted0_a_abs_c_idx on mcrparted0 mcrparted_1 + Skip scan: All -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All -> Index Scan using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All -> Index Scan using mcrparted4_a_abs_c_idx on mcrparted4 mcrparted_5 + Skip scan: All -> Index Scan using mcrparted5_a_abs_c_idx on mcrparted5 mcrparted_6 -(7 rows) + Skip scan: All +(13 rows) -- Append is used with subpaths in reverse order with backwards index scans explain (costs off) select * from mcrparted order by a desc, abs(b) desc, c desc; @@ -2122,12 +2165,18 @@ explain (costs off) select * from mcrparted order by a desc, abs(b) desc, c desc ---------------------------------------------------------------------------------- Append -> Index Scan Backward using mcrparted5_a_abs_c_idx on mcrparted5 mcrparted_6 + Skip scan: All -> Index Scan Backward using mcrparted4_a_abs_c_idx on mcrparted4 mcrparted_5 + Skip scan: All -> Index Scan Backward using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All -> Index Scan Backward using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All -> Index Scan Backward using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All -> Index Scan Backward using mcrparted0_a_abs_c_idx on mcrparted0 mcrparted_1 -(7 rows) + Skip scan: All +(13 rows) -- check that Append plan is used containing a MergeAppend for sub-partitions -- that are unordered. @@ -2140,15 +2189,22 @@ explain (costs off) select * from mcrparted order by a, abs(b), c; --------------------------------------------------------------------------------------- Append -> Index Scan using mcrparted0_a_abs_c_idx on mcrparted0 mcrparted_1 + Skip scan: All -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All -> Index Scan using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All -> Index Scan using mcrparted4_a_abs_c_idx on mcrparted4 mcrparted_5 + Skip scan: All -> Merge Append Sort Key: mcrparted_7.a, (abs(mcrparted_7.b)), mcrparted_7.c -> Index Scan using mcrparted5a_a_abs_c_idx on mcrparted5a mcrparted_7 + Skip scan: All -> Index Scan using mcrparted5_def_a_abs_c_idx on mcrparted5_def mcrparted_8 -(10 rows) + Skip scan: All +(17 rows) drop table mcrparted5_def; -- check that an Append plan is used and the sub-partitions are flattened @@ -2159,12 +2215,18 @@ explain (costs off) select a, abs(b) from mcrparted order by a, abs(b), c; --------------------------------------------------------------------------- Append -> Index Scan using mcrparted0_a_abs_c_idx on mcrparted0 mcrparted_1 + Skip scan: All -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All -> Index Scan using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All -> Index Scan using mcrparted4_a_abs_c_idx on mcrparted4 mcrparted_5 + Skip scan: All -> Index Scan using mcrparted5a_a_abs_c_idx on mcrparted5a mcrparted_6 -(7 rows) + Skip scan: All +(13 rows) -- check that Append is used when the sub-partitioned tables are pruned -- during planning. @@ -2173,14 +2235,18 @@ explain (costs off) select * from mcrparted where a < 20 order by a, abs(b), c; ------------------------------------------------------------------------- Append -> Index Scan using mcrparted0_a_abs_c_idx on mcrparted0 mcrparted_1 + Skip scan: All Index Cond: (a < 20) -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All Index Cond: (a < 20) -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All Index Cond: (a < 20) -> Index Scan using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All Index Cond: (a < 20) -(9 rows) +(13 rows) create table mclparted (a int) partition by list(a); create table mclparted1 partition of mclparted for values in(1); @@ -2192,8 +2258,10 @@ explain (costs off) select * from mclparted order by a; ------------------------------------------------------------------------ Append -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1 + Skip scan: All -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2 -(3 rows) + Skip scan: All +(5 rows) -- Ensure a MergeAppend is used when a partition exists with interleaved -- datums in the partition bound. @@ -2205,10 +2273,14 @@ explain (costs off) select * from mclparted order by a; Merge Append Sort Key: mclparted.a -> Index Only Scan using mclparted1_a_idx on mclparted1 mclparted_1 + Skip scan: All -> Index Only Scan using mclparted2_a_idx on mclparted2 mclparted_2 + Skip scan: All -> Index Only Scan using mclparted3_5_a_idx on mclparted3_5 mclparted_3 + Skip scan: All -> Index Only Scan using mclparted4_a_idx on mclparted4 mclparted_4 -(6 rows) + Skip scan: All +(10 rows) drop table mclparted; -- Ensure subplans which don't have a path with the correct pathkeys get @@ -2228,12 +2300,15 @@ explain (costs off) select * from mcrparted where a < 20 order by a, abs(b), c l -> Seq Scan on mcrparted0 mcrparted_1 Filter: (a < 20) -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_2 + Skip scan: All Index Cond: (a < 20) -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_3 + Skip scan: All Index Cond: (a < 20) -> Index Scan using mcrparted3_a_abs_c_idx on mcrparted3 mcrparted_4 + Skip scan: All Index Cond: (a < 20) -(12 rows) +(15 rows) set enable_bitmapscan = 0; -- Ensure Append node can be used when the partition is ordered by some @@ -2243,10 +2318,12 @@ explain (costs off) select * from mcrparted where a = 10 order by a, abs(b), c; ------------------------------------------------------------------------- Append -> Index Scan using mcrparted1_a_abs_c_idx on mcrparted1 mcrparted_1 + Skip scan: All Index Cond: (a = 10) -> Index Scan using mcrparted2_a_abs_c_idx on mcrparted2 mcrparted_2 + Skip scan: All Index Cond: (a = 10) -(5 rows) +(7 rows) reset enable_bitmapscan; drop table mcrparted; @@ -2260,8 +2337,10 @@ explain (costs off) select * from bool_lp order by b; ---------------------------------------------------------------------------- Append -> Index Only Scan using bool_lp_false_b_idx on bool_lp_false bool_lp_1 + Skip scan: All -> Index Only Scan using bool_lp_true_b_idx on bool_lp_true bool_lp_2 -(3 rows) + Skip scan: All +(5 rows) drop table bool_lp; -- Ensure const bool quals can be properly detected as redundant @@ -2276,40 +2355,48 @@ explain (costs off) select * from bool_rp where b = true order by b,a; ---------------------------------------------------------------------------------- Append -> Index Only Scan using bool_rp_true_1k_b_a_idx on bool_rp_true_1k bool_rp_1 + Skip scan: All Index Cond: (b = true) -> Index Only Scan using bool_rp_true_2k_b_a_idx on bool_rp_true_2k bool_rp_2 + Skip scan: All Index Cond: (b = true) -(5 rows) +(7 rows) explain (costs off) select * from bool_rp where b = false order by b,a; QUERY PLAN ------------------------------------------------------------------------------------ Append -> Index Only Scan using bool_rp_false_1k_b_a_idx on bool_rp_false_1k bool_rp_1 + Skip scan: All Index Cond: (b = false) -> Index Only Scan using bool_rp_false_2k_b_a_idx on bool_rp_false_2k bool_rp_2 + Skip scan: All Index Cond: (b = false) -(5 rows) +(7 rows) explain (costs off) select * from bool_rp where b = true order by a; QUERY PLAN ---------------------------------------------------------------------------------- Append -> Index Only Scan using bool_rp_true_1k_b_a_idx on bool_rp_true_1k bool_rp_1 + Skip scan: All Index Cond: (b = true) -> Index Only Scan using bool_rp_true_2k_b_a_idx on bool_rp_true_2k bool_rp_2 + Skip scan: All Index Cond: (b = true) -(5 rows) +(7 rows) explain (costs off) select * from bool_rp where b = false order by a; QUERY PLAN ------------------------------------------------------------------------------------ Append -> Index Only Scan using bool_rp_false_1k_b_a_idx on bool_rp_false_1k bool_rp_1 + Skip scan: All Index Cond: (b = false) -> Index Only Scan using bool_rp_false_2k_b_a_idx on bool_rp_false_2k bool_rp_2 + Skip scan: All Index Cond: (b = false) -(5 rows) +(7 rows) drop table bool_rp; -- Ensure an Append scan is chosen when the partition order is a subset of @@ -2323,16 +2410,20 @@ explain (costs off) select * from range_parted order by a,b,c; ------------------------------------------------------------------------------------- Append -> Index Only Scan using range_parted1_a_b_c_idx on range_parted1 range_parted_1 + Skip scan: All -> Index Only Scan using range_parted2_a_b_c_idx on range_parted2 range_parted_2 -(3 rows) + Skip scan: All +(5 rows) explain (costs off) select * from range_parted order by a desc,b desc,c desc; QUERY PLAN ---------------------------------------------------------------------------------------------- Append -> Index Only Scan Backward using range_parted2_a_b_c_idx on range_parted2 range_parted_2 + Skip scan: All -> Index Only Scan Backward using range_parted1_a_b_c_idx on range_parted1 range_parted_1 -(3 rows) + Skip scan: All +(5 rows) drop table range_parted; -- Check that we allow access to a child table's statistics when the user diff --git a/src/test/regress/expected/insert_conflict.out b/src/test/regress/expected/insert_conflict.out index 1338b2b23e..e7eae05abf 100644 --- a/src/test/regress/expected/insert_conflict.out +++ b/src/test/regress/expected/insert_conflict.out @@ -54,10 +54,11 @@ explain (costs off) insert into insertconflicttest values(0, 'Crowberry') on con -> Result SubPlan 1 -> Index Only Scan using both_index_expr_key on insertconflicttest ii + Skip scan: All Index Cond: (key = excluded.key) SubPlan 2 -> Seq Scan on insertconflicttest ii_1 -(10 rows) +(11 rows) -- Neither collation nor operator class specifications are required -- -- supplying them merely *limits* matches to indexes with matching opclasses diff --git a/src/test/regress/expected/interval.out b/src/test/regress/expected/interval.out index f772909e49..09131c5933 100644 --- a/src/test/regress/expected/interval.out +++ b/src/test/regress/expected/interval.out @@ -260,7 +260,8 @@ SELECT f1 FROM INTERVAL_TBL_OF r1 ORDER BY f1; QUERY PLAN -------------------------------------------------------------------- Index Only Scan using interval_tbl_of_f1_idx on interval_tbl_of r1 -(1 row) + Skip scan: All +(2 rows) SELECT f1 FROM INTERVAL_TBL_OF r1 ORDER BY f1; f1 diff --git a/src/test/regress/expected/join.out b/src/test/regress/expected/join.out index 761376b007..789cb32585 100644 --- a/src/test/regress/expected/join.out +++ b/src/test/regress/expected/join.out @@ -1857,16 +1857,16 @@ select * from int4_tbl i4, tenk1 a where exists(select * from tenk1 b where a.twothousand = b.twothousand and a.fivethous <> b.fivethous) and i4.f1 = a.tenthous; - QUERY PLAN ----------------------------------------------- + QUERY PLAN +-------------------------------------------------------------- Hash Semi Join Hash Cond: (a.twothousand = b.twothousand) Join Filter: (a.fivethous <> b.fivethous) - -> Hash Join - Hash Cond: (a.tenthous = i4.f1) - -> Seq Scan on tenk1 a - -> Hash - -> Seq Scan on int4_tbl i4 + -> Nested Loop + -> Seq Scan on int4_tbl i4 + -> Index Scan using tenk1_thous_tenthous on tenk1 a + Skip scan: All + Index Cond: (tenthous = i4.f1) -> Hash -> Seq Scan on tenk1 b (10 rows) @@ -2293,8 +2293,9 @@ where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous; -> Aggregate -> Seq Scan on int4_tbl i4a -> Index Only Scan using tenk1_thous_tenthous on tenk1 t + Skip scan: All Index Cond: ((thousand = (sum(i4b.f1))) AND (tenthous = ((((sum(i4a.f1) + 1)) + (sum(i4b.f1))) + 999))) -(9 rows) +(10 rows) select a.f1, b.f1, t.thousand, t.tenthous from tenk1 t, @@ -2373,7 +2374,8 @@ select count(*) from -> Seq Scan on tenk1 x -> Materialize -> Index Scan using tenk1_unique2 on tenk1 y -(9 rows) + Skip scan: All +(10 rows) select count(*) from (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x @@ -2493,10 +2495,11 @@ select count(*) from tenk1 a, tenk1 b -> Hash Join Hash Cond: (a.hundred = b.thousand) -> Index Only Scan using tenk1_hundred on tenk1 a + Skip scan: All -> Hash -> Seq Scan on tenk1 b Filter: ((fivethous % 10) < 10) -(7 rows) +(8 rows) select count(*) from tenk1 a, tenk1 b where a.hundred = b.thousand and (b.fivethous % 10) < 10; @@ -2702,9 +2705,11 @@ select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv; Merge Join Merge Cond: (a.idv = b.idv) -> Index Only Scan using tidv_idv_idx on tidv a + Skip scan: All -> Materialize -> Index Only Scan using tidv_idv_idx on tidv b -(5 rows) + Skip scan: All +(7 rows) set enable_mergejoin = 0; explain (costs off) @@ -2714,8 +2719,9 @@ select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv; Nested Loop -> Seq Scan on tidv a -> Index Only Scan using tidv_idv_idx on tidv b + Skip scan: All Index Cond: (idv = a.idv) -(4 rows) +(5 rows) rollback; -- @@ -2874,8 +2880,9 @@ SELECT qq, unique1 -> Hash -> Seq Scan on int8_tbl b -> Index Scan using tenk1_unique2 on tenk1 c + Skip scan: All Index Cond: (unique2 = COALESCE((COALESCE(a.q1, '0'::bigint)), (COALESCE(b.q2, '-1'::bigint)))) -(8 rows) +(9 rows) SELECT qq, unique1 FROM @@ -2938,13 +2945,16 @@ where nt3.id = 1 and ss2.b3; Nested Loop -> Nested Loop -> Index Scan using nt3_pkey on nt3 + Skip scan: All Index Cond: (id = 1) -> Index Scan using nt2_pkey on nt2 + Skip scan: All Index Cond: (id = nt3.nt2_id) -> Index Only Scan using nt1_pkey on nt1 + Skip scan: All Index Cond: (id = nt2.nt1_id) Filter: (nt2.b1 AND (id IS NOT NULL)) -(9 rows) +(12 rows) select nt3.id from nt3 as nt3 @@ -3081,12 +3091,14 @@ where q1 = thousand or q2 = thousand; Recheck Cond: ((q1.q1 = thousand) OR (q2.q2 = thousand)) -> BitmapOr -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = q1.q1) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = q2.q2) -> Hash -> Seq Scan on int4_tbl -(15 rows) +(17 rows) explain (costs off) select * from @@ -3104,10 +3116,11 @@ where thousand = (q1 + q2); -> Bitmap Heap Scan on tenk1 Recheck Cond: (thousand = (q1.q1 + q2.q2)) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = (q1.q1 + q2.q2)) -> Hash -> Seq Scan on int4_tbl -(12 rows) +(13 rows) -- -- test ability to generate a suitable plan for a star-schema query @@ -3116,17 +3129,19 @@ explain (costs off) select * from tenk1, int8_tbl a, int8_tbl b where thousand = a.q1 and tenthous = b.q1 and a.q2 = 1 and b.q2 = 2; - QUERY PLAN ---------------------------------------------------------------------- + QUERY PLAN +------------------------------------------------------------ Nested Loop - -> Seq Scan on int8_tbl b - Filter: (q2 = 2) + Join Filter: (tenk1.thousand = a.q1) -> Nested Loop - -> Seq Scan on int8_tbl a - Filter: (q2 = 1) + -> Seq Scan on int8_tbl b + Filter: (q2 = 2) -> Index Scan using tenk1_thous_tenthous on tenk1 - Index Cond: ((thousand = a.q1) AND (tenthous = b.q1)) -(8 rows) + Skip scan: All + Index Cond: (tenthous = b.q1) + -> Seq Scan on int8_tbl a + Filter: (q2 = 1) +(10 rows) -- -- test a corner case in which we shouldn't apply the star-schema optimization @@ -3154,12 +3169,14 @@ where t1.unique2 < 42 and t1.stringu1 > t2.stringu2; -> Seq Scan on onerow -> Seq Scan on onerow onerow_1 -> Index Scan using tenk1_unique2 on tenk1 t1 + Skip scan: All Index Cond: ((unique2 = (11)) AND (unique2 < 42)) -> Index Scan using tenk1_unique1 on tenk1 t2 + Skip scan: All Index Cond: (unique1 = (3)) -> Seq Scan on int4_tbl i1 Filter: (f1 = 0) -(13 rows) +(15 rows) select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from tenk1 t1 @@ -3220,10 +3237,12 @@ where t1.unique2 < 42 and t1.stringu1 > t2.stringu2; -> Seq Scan on int4_tbl i1 Filter: (f1 = 0) -> Index Scan using tenk1_unique2 on tenk1 t1 + Skip scan: All Index Cond: ((unique2 = (11)) AND (unique2 < 42)) -> Index Scan using tenk1_unique1 on tenk1 t2 + Skip scan: All Index Cond: (unique1 = (3)) -(9 rows) +(11 rows) select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from tenk1 t1 @@ -3280,8 +3299,9 @@ where x = unique1; QUERY PLAN ---------------------------------------------- Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = 1) -(2 rows) +(3 rows) explain (verbose, costs off) select unique1, x.* @@ -3295,32 +3315,36 @@ where x = unique1; Output: 1, random() -> Index Only Scan using tenk1_unique1 on public.tenk1 Output: tenk1.unique1 + Skip scan: All Index Cond: (tenk1.unique1 = (1)) -(7 rows) +(8 rows) explain (costs off) select unique1 from tenk1, f_immutable_int4(1) x where x = unique1; QUERY PLAN ---------------------------------------------- Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = 1) -(2 rows) +(3 rows) explain (costs off) select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1; QUERY PLAN ---------------------------------------------- Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = 1) -(2 rows) +(3 rows) explain (costs off) select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x; QUERY PLAN ---------------------------------------------- Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = 1) -(2 rows) +(3 rows) explain (costs off) select unique1, x from tenk1 left join f_immutable_int4(1) x on unique1 = x; @@ -3329,9 +3353,10 @@ select unique1, x from tenk1 left join f_immutable_int4(1) x on unique1 = x; Nested Loop Left Join Join Filter: (tenk1.unique1 = 1) -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All -> Materialize -> Result -(5 rows) +(6 rows) explain (costs off) select unique1, x from tenk1 right join f_immutable_int4(1) x on unique1 = x; @@ -3340,8 +3365,9 @@ select unique1, x from tenk1 right join f_immutable_int4(1) x on unique1 = x; Nested Loop Left Join -> Result -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = 1) -(4 rows) +(5 rows) explain (costs off) select unique1, x from tenk1 full join f_immutable_int4(1) x on unique1 = x; @@ -3350,10 +3376,11 @@ select unique1, x from tenk1 full join f_immutable_int4(1) x on unique1 = x; Merge Full Join Merge Cond: (tenk1.unique1 = (1)) -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All -> Sort Sort Key: (1) -> Result -(6 rows) +(7 rows) -- check that pullup of a const function allows further const-folding explain (costs off) @@ -3382,13 +3409,15 @@ where nt3.id = 1 and ss2.b3; Nested Loop Left Join Filter: ((nt2.b1 OR ((0) = 42))) -> Index Scan using nt3_pkey on nt3 + Skip scan: All Index Cond: (id = 1) -> Nested Loop Left Join Join Filter: (0 = nt2.nt1_id) -> Index Scan using nt2_pkey on nt2 + Skip scan: All Index Cond: (id = nt3.nt2_id) -> Result -(9 rows) +(11 rows) drop function f_immutable_int4(int); -- test inlining when function returns composite @@ -3443,18 +3472,22 @@ select * from tenk1 a join tenk1 b on Recheck Cond: ((unique1 = 2) OR (hundred = 4)) -> BitmapOr -> Bitmap Index Scan on tenk1_unique1 + Skip scan: All Index Cond: (unique1 = 2) -> Bitmap Index Scan on tenk1_hundred + Skip scan: All Index Cond: (hundred = 4) -> Materialize -> Bitmap Heap Scan on tenk1 a Recheck Cond: ((unique1 = 1) OR (unique2 = 3)) -> BitmapOr -> Bitmap Index Scan on tenk1_unique1 + Skip scan: All Index Cond: (unique1 = 1) -> Bitmap Index Scan on tenk1_unique2 + Skip scan: All Index Cond: (unique2 = 3) -(17 rows) +(21 rows) explain (costs off) select * from tenk1 a join tenk1 b on @@ -3470,10 +3503,12 @@ select * from tenk1 a join tenk1 b on Recheck Cond: ((unique1 = 1) OR (unique2 = 3)) -> BitmapOr -> Bitmap Index Scan on tenk1_unique1 + Skip scan: All Index Cond: (unique1 = 1) -> Bitmap Index Scan on tenk1_unique2 + Skip scan: All Index Cond: (unique2 = 3) -(12 rows) +(14 rows) explain (costs off) select * from tenk1 a join tenk1 b on @@ -3487,20 +3522,25 @@ select * from tenk1 a join tenk1 b on Recheck Cond: ((unique1 = 2) OR (hundred = 4)) -> BitmapOr -> Bitmap Index Scan on tenk1_unique1 + Skip scan: All Index Cond: (unique1 = 2) -> Bitmap Index Scan on tenk1_hundred + Skip scan: All Index Cond: (hundred = 4) -> Materialize -> Bitmap Heap Scan on tenk1 a Recheck Cond: ((unique1 = 1) OR (unique2 = 3) OR (unique2 = 7)) -> BitmapOr -> Bitmap Index Scan on tenk1_unique1 + Skip scan: All Index Cond: (unique1 = 1) -> Bitmap Index Scan on tenk1_unique2 + Skip scan: All Index Cond: (unique2 = 3) -> Bitmap Index Scan on tenk1_unique2 + Skip scan: All Index Cond: (unique2 = 7) -(19 rows) +(24 rows) -- -- test placement of movable quals in a parameterized join tree @@ -3514,16 +3554,19 @@ where t1.unique1 = 1; -------------------------------------------------------- Nested Loop Left Join -> Index Scan using tenk1_unique1 on tenk1 t1 + Skip scan: All Index Cond: (unique1 = 1) -> Nested Loop Join Filter: (t1.ten = t3.ten) -> Bitmap Heap Scan on tenk1 t2 Recheck Cond: (t1.hundred = hundred) -> Bitmap Index Scan on tenk1_hundred + Skip scan: All Index Cond: (hundred = t1.hundred) -> Index Scan using tenk1_unique2 on tenk1 t3 + Skip scan: All Index Cond: (unique2 = t2.thousand) -(11 rows) +(14 rows) explain (costs off) select * from tenk1 t1 left join @@ -3534,16 +3577,19 @@ where t1.unique1 = 1; -------------------------------------------------------- Nested Loop Left Join -> Index Scan using tenk1_unique1 on tenk1 t1 + Skip scan: All Index Cond: (unique1 = 1) -> Nested Loop Join Filter: ((t1.ten + t2.ten) = t3.ten) -> Bitmap Heap Scan on tenk1 t2 Recheck Cond: (t1.hundred = hundred) -> Bitmap Index Scan on tenk1_hundred + Skip scan: All Index Cond: (hundred = t1.hundred) -> Index Scan using tenk1_unique2 on tenk1 t3 + Skip scan: All Index Cond: (unique2 = t2.thousand) -(11 rows) +(14 rows) explain (costs off) select count(*) from @@ -3561,12 +3607,15 @@ select count(*) from -> Bitmap Heap Scan on tenk1 b Recheck Cond: (thousand = int4_tbl.f1) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = int4_tbl.f1) -> Index Scan using tenk1_unique1 on tenk1 a + Skip scan: All Index Cond: (unique1 = b.unique2) -> Index Only Scan using tenk1_thous_tenthous on tenk1 c + Skip scan: All Index Cond: (thousand = a.thousand) -(14 rows) +(17 rows) select count(*) from tenk1 a join tenk1 b on a.unique1 = b.unique2 @@ -3584,24 +3633,28 @@ select b.unique1 from join int4_tbl i1 on b.thousand = f1 right join int4_tbl i2 on i2.f1 = b.tenthous order by 1; - QUERY PLAN ------------------------------------------------------------------------------------------ + QUERY PLAN +-------------------------------------------------------------------------------- Sort Sort Key: b.unique1 -> Nested Loop Left Join -> Seq Scan on int4_tbl i2 - -> Nested Loop Left Join - Join Filter: (b.unique1 = 42) - -> Nested Loop + -> Nested Loop + Join Filter: (b.thousand = i1.f1) + -> Nested Loop Left Join + Join Filter: (b.unique1 = 42) -> Nested Loop - -> Seq Scan on int4_tbl i1 -> Index Scan using tenk1_thous_tenthous on tenk1 b - Index Cond: ((thousand = i1.f1) AND (tenthous = i2.f1)) - -> Index Scan using tenk1_unique1 on tenk1 a - Index Cond: (unique1 = b.unique2) - -> Index Only Scan using tenk1_thous_tenthous on tenk1 c - Index Cond: (thousand = a.thousand) -(15 rows) + Skip scan: All + Index Cond: (tenthous = i2.f1) + -> Index Scan using tenk1_unique1 on tenk1 a + Skip scan: All + Index Cond: (unique1 = b.unique2) + -> Index Only Scan using tenk1_thous_tenthous on tenk1 c + Skip scan: All + Index Cond: (thousand = a.thousand) + -> Seq Scan on int4_tbl i1 +(19 rows) select b.unique1 from tenk1 a join tenk1 b on a.unique1 = b.unique2 @@ -3632,8 +3685,9 @@ order by fault; Filter: ((COALESCE(tenk1.unique1, '-1'::integer) + int8_tbl.q1) = 122) -> Seq Scan on int8_tbl -> Index Scan using tenk1_unique2 on tenk1 + Skip scan: All Index Cond: (unique2 = int8_tbl.q2) -(5 rows) +(6 rows) select * from ( @@ -3687,8 +3741,9 @@ select q1, unique2, thousand, hundred Filter: ((COALESCE(b.thousand, 123) = a.q1) AND (a.q1 = COALESCE(b.hundred, 123))) -> Seq Scan on int8_tbl a -> Index Scan using tenk1_unique2 on tenk1 b + Skip scan: All Index Cond: (unique2 = a.q1) -(5 rows) +(6 rows) select q1, unique2, thousand, hundred from int8_tbl a left join tenk1 b on q1 = unique2 @@ -3707,8 +3762,9 @@ select f1, unique2, case when unique2 is null then f1 else 0 end Filter: (CASE WHEN (b.unique2 IS NULL) THEN a.f1 ELSE 0 END = 0) -> Seq Scan on int4_tbl a -> Index Only Scan using tenk1_unique2 on tenk1 b + Skip scan: All Index Cond: (unique2 = a.f1) -(5 rows) +(6 rows) select f1, unique2, case when unique2 is null then f1 else 0 end from int4_tbl a left join tenk1 b on f1 = unique2 @@ -3731,14 +3787,17 @@ select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) -> Nested Loop Left Join Filter: (COALESCE(b.twothousand, a.twothousand) = 44) -> Index Scan using tenk1_unique2 on tenk1 a + Skip scan: All Index Cond: (unique2 < 10) -> Bitmap Heap Scan on tenk1 b Recheck Cond: (thousand = a.unique1) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand = a.unique1) -> Index Scan using tenk1_unique2 on tenk1 c + Skip scan: All Index Cond: ((unique2 = COALESCE(b.twothousand, a.twothousand)) AND (unique2 = 44)) -(11 rows) +(14 rows) select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand) from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand) @@ -3778,8 +3837,9 @@ using (join_key); Output: i1.f1 -> Index Only Scan using tenk1_unique2 on public.tenk1 i2 Output: i2.unique2 + Skip scan: All Index Cond: (i2.unique2 = i1.f1) -(14 rows) +(15 rows) select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from (values (0),(1)) foo1(join_key) @@ -4281,8 +4341,9 @@ explain (costs off) -> Seq Scan on int4_tbl a Filter: (f1 = 0) -> Index Scan using tenk1_unique2 on tenk1 b + Skip scan: All Index Cond: (unique2 = 0) -(6 rows) +(7 rows) explain (costs off) select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42; @@ -4291,10 +4352,12 @@ explain (costs off) Merge Full Join Merge Cond: (a.unique2 = b.unique2) -> Index Scan using tenk1_unique2 on tenk1 a + Skip scan: All Index Cond: (unique2 = 42) -> Index Scan using tenk1_unique2 on tenk1 b + Skip scan: All Index Cond: (unique2 = 42) -(6 rows) +(8 rows) -- -- test that quals attached to an outer join have correct semantics, @@ -4424,10 +4487,11 @@ select d.* from d left join (select * from b group by b.id, b.c_id) s -> Group Group Key: b.id -> Index Scan using b_pkey on b + Skip scan: All -> Sort Sort Key: d.a -> Seq Scan on d -(8 rows) +(9 rows) -- similarly, but keying off a DISTINCT clause explain (costs off) @@ -4539,8 +4603,9 @@ select p.* from Result One-Time Filter: false -> Index Scan using parent_pkey on parent p + Skip scan: All Index Cond: (k = 1) -(4 rows) +(5 rows) select p.* from (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k @@ -4632,11 +4697,12 @@ where ss.stringu2 !~* ss.case1; -> Nested Loop -> Seq Scan on int4_tbl i4 -> Index Scan using tenk1_unique2 on tenk1 t1 + Skip scan: All Index Cond: (unique2 = i4.f1) Filter: (stringu2 !~* CASE ten WHEN 0 THEN 'doh!'::text ELSE NULL::text END) -> Materialize -> Seq Scan on text_tbl t0 -(9 rows) +(10 rows) select t0.* from @@ -4723,8 +4789,9 @@ explain (costs off) Nested Loop -> Seq Scan on int4_tbl b -> Index Scan using tenk1_unique1 on tenk1 a + Skip scan: All Index Cond: (unique1 = b.f1) -(4 rows) +(5 rows) select unique2, x.* from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss; @@ -4741,8 +4808,9 @@ explain (costs off) Nested Loop -> Seq Scan on int4_tbl x -> Index Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = x.f1) -(4 rows) +(5 rows) explain (costs off) select unique2, x.* @@ -4752,8 +4820,9 @@ explain (costs off) Nested Loop -> Seq Scan on int4_tbl x -> Index Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = x.f1) -(4 rows) +(5 rows) select unique2, x.* from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true; @@ -4774,8 +4843,9 @@ explain (costs off) Nested Loop Left Join -> Seq Scan on int4_tbl x -> Index Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = x.f1) -(4 rows) +(5 rows) -- check scoping of lateral versus parent references -- the first of these should return int8_tbl.q2, the second int8_tbl.q1 @@ -4873,8 +4943,10 @@ explain (costs off) -> Merge Join Merge Cond: (a.unique1 = b.unique2) -> Index Only Scan using tenk1_unique1 on tenk1 a + Skip scan: All -> Index Only Scan using tenk1_unique2 on tenk1 b -(5 rows) + Skip scan: All +(7 rows) select count(*) from tenk1 a, tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x; @@ -4894,10 +4966,12 @@ explain (costs off) Hash Cond: ("*VALUES*".column1 = b.unique2) -> Nested Loop -> Index Only Scan using tenk1_unique1 on tenk1 a + Skip scan: All -> Values Scan on "*VALUES*" -> Hash -> Index Only Scan using tenk1_unique2 on tenk1 b -(8 rows) + Skip scan: All +(10 rows) select count(*) from tenk1 a, tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x; @@ -5638,8 +5712,9 @@ select * from Output: tenk1.unique1 -> Index Scan using tenk1_unique2 on public.tenk1 Output: tenk1.unique1 + Skip scan: All Index Cond: (tenk1.unique2 = "*VALUES*".column2) -(14 rows) +(15 rows) select * from (values (0,9998), (1,1000)) v(id,x), @@ -5867,14 +5942,18 @@ where f.c = 1; -> Nested Loop Left Join -> Nested Loop Left Join -> Index Scan using fkest_c_key on fkest f + Skip scan: All Index Cond: (c = 1) -> Index Only Scan using fkest1_pkey on fkest1 f1 + Skip scan: All Index Cond: ((a = f.a) AND (b = f.b)) -> Index Only Scan using fkest1_pkey on fkest1 f2 + Skip scan: All Index Cond: ((a = f.a) AND (b = f.b)) -> Index Only Scan using fkest1_pkey on fkest1 f3 + Skip scan: All Index Cond: ((a = f.a) AND (b = f.b)) -(11 rows) +(15 rows) rollback; -- @@ -6164,8 +6243,10 @@ where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1; Merge Cond: (j1.id1 = j2.id1) Join Filter: (j1.id2 = j2.id2) -> Index Scan using j1_id1_idx on j1 + Skip scan: All -> Index Scan using j2_id1_idx on j2 -(5 rows) + Skip scan: All +(7 rows) select * from j1 inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2 @@ -6201,15 +6282,18 @@ where exists (select 1 from tenk1 t3 Group Key: t3.thousand, t3.tenthous -> Index Only Scan using tenk1_thous_tenthous on public.tenk1 t3 Output: t3.thousand, t3.tenthous + Skip scan: All -> Hash Output: t1.unique1 -> Index Only Scan using onek_unique1 on public.onek t1 Output: t1.unique1 + Skip scan: All Index Cond: (t1.unique1 < 1) -> Index Only Scan using tenk1_hundred on public.tenk1 t2 Output: t2.hundred + Skip scan: All Index Cond: (t2.hundred = t3.tenthous) -(18 rows) +(21 rows) -- ... unless it actually is unique create table j3 as select unique1, tenthous from onek; @@ -6229,13 +6313,16 @@ where exists (select 1 from j3 Output: t1.unique1, j3.tenthous -> Index Only Scan using onek_unique1 on public.onek t1 Output: t1.unique1 + Skip scan: All Index Cond: (t1.unique1 < 1) -> Index Only Scan using j3_unique1_tenthous_idx on public.j3 Output: j3.unique1, j3.tenthous + Skip scan: All Index Cond: (j3.unique1 = t1.unique1) -> Index Only Scan using tenk1_hundred on public.tenk1 t2 Output: t2.hundred + Skip scan: All Index Cond: (t2.hundred = j3.tenthous) -(13 rows) +(16 rows) drop table j3; diff --git a/src/test/regress/expected/limit.out b/src/test/regress/expected/limit.out index c18f547cbd..3e7085b379 100644 --- a/src/test/regress/expected/limit.out +++ b/src/test/regress/expected/limit.out @@ -322,7 +322,8 @@ select unique1, unique2, nextval('testseq') Output: unique1, unique2, (nextval('testseq'::regclass)) -> Index Scan using tenk1_unique2 on public.tenk1 Output: unique1, unique2, nextval('testseq'::regclass) -(4 rows) + Skip scan: All +(5 rows) select unique1, unique2, nextval('testseq') from tenk1 order by unique2 limit 10; @@ -395,7 +396,8 @@ select unique1, unique2, generate_series(1,10) Output: unique1, unique2, generate_series(1, 10) -> Index Scan using tenk1_unique2 on public.tenk1 Output: unique1, unique2, two, four, ten, twenty, hundred, thousand, twothousand, fivethous, tenthous, odd, even, stringu1, stringu2, string4 -(6 rows) + Skip scan: All +(7 rows) select unique1, unique2, generate_series(1,10) from tenk1 order by unique2 limit 7; @@ -492,7 +494,8 @@ select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 Group Key: tenk1.thousand -> Index Only Scan using tenk1_thous_tenthous on public.tenk1 Output: thousand, tenthous -(7 rows) + Skip scan: All +(8 rows) select sum(tenthous) as s1, sum(tenthous) + random()*0 as s2 from tenk1 group by thousand order by thousand limit 3; diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out index d3acb98d04..ee6bcc4b1b 100644 --- a/src/test/regress/expected/misc_functions.out +++ b/src/test/regress/expected/misc_functions.out @@ -232,8 +232,9 @@ WHERE my_int_eq(a.unique2, 42); -> Seq Scan on tenk1 a Filter: my_int_eq(unique2, 42) -> Index Scan using tenk1_unique1 on tenk1 b + Skip scan: All Index Cond: (unique1 = a.unique1) -(5 rows) +(6 rows) -- Also test non-default rowcount estimate CREATE FUNCTION my_gen_series(int, int) RETURNS SETOF integer @@ -258,6 +259,7 @@ SELECT * FROM tenk1 a JOIN my_gen_series(1,10) g ON a.unique1 = g; Nested Loop -> Function Scan on my_gen_series g -> Index Scan using tenk1_unique1 on tenk1 a + Skip scan: All Index Cond: (unique1 = g.g) -(4 rows) +(5 rows) diff --git a/src/test/regress/expected/partition_join.out b/src/test/regress/expected/partition_join.out index b3fbe47bde..a1a52212a7 100644 --- a/src/test/regress/expected/partition_join.out +++ b/src/test/regress/expected/partition_join.out @@ -126,8 +126,9 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHE -> Seq Scan on prt2_p3 t2_3 Filter: (a = 0) -> Index Scan using iprt1_p3_a on prt1_p3 t1_3 + Skip scan: All Index Cond: (a = t2_3.b) -(20 rows) +(21 rows) SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 RIGHT JOIN prt2 t2 ON t1.a = t2.b WHERE t2.a = 0 ORDER BY t1.a, t2.b; a | c | b | c @@ -366,26 +367,32 @@ SELECT * FROM prt1 t1 LEFT JOIN LATERAL Filter: (b = 0) -> Nested Loop -> Index Only Scan using iprt1_p1_a on prt1_p1 t2_1 + Skip scan: All Index Cond: (a = t1_1.a) -> Index Scan using iprt2_p1_b on prt2_p1 t3_1 + Skip scan: All Index Cond: (b = t2_1.a) -> Nested Loop Left Join -> Seq Scan on prt1_p2 t1_2 Filter: (b = 0) -> Nested Loop -> Index Only Scan using iprt1_p2_a on prt1_p2 t2_2 + Skip scan: All Index Cond: (a = t1_2.a) -> Index Scan using iprt2_p2_b on prt2_p2 t3_2 + Skip scan: All Index Cond: (b = t2_2.a) -> Nested Loop Left Join -> Seq Scan on prt1_p3 t1_3 Filter: (b = 0) -> Nested Loop -> Index Only Scan using iprt1_p3_a on prt1_p3 t2_3 + Skip scan: All Index Cond: (a = t1_3.a) -> Index Scan using iprt2_p3_b on prt2_p3 t3_3 + Skip scan: All Index Cond: (b = t2_3.a) -(27 rows) +(33 rows) SELECT * FROM prt1 t1 LEFT JOIN LATERAL (SELECT t2.a AS t2a, t3.a AS t3a, least(t1.a,t2.a,t3.b) FROM prt1 t2 JOIN prt2 t3 ON (t2.a = t3.b)) ss @@ -609,6 +616,7 @@ SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t -> Seq Scan on prt1_p1 t1_1 Filter: (b = 0) -> Index Scan using iprt1_e_p1_ab2 on prt1_e_p1 t3_1 + Skip scan: All Index Cond: (((a + b) / 2) = t2_1.b) -> Nested Loop Join Filter: (t1_2.a = ((t3_2.a + t3_2.b) / 2)) @@ -619,6 +627,7 @@ SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t -> Seq Scan on prt1_p2 t1_2 Filter: (b = 0) -> Index Scan using iprt1_e_p2_ab2 on prt1_e_p2 t3_2 + Skip scan: All Index Cond: (((a + b) / 2) = t2_2.b) -> Nested Loop Join Filter: (t1_3.a = ((t3_3.a + t3_3.b) / 2)) @@ -629,8 +638,9 @@ SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t -> Seq Scan on prt1_p3 t1_3 Filter: (b = 0) -> Index Scan using iprt1_e_p3_ab2 on prt1_e_p3 t3_3 + Skip scan: All Index Cond: (((a + b) / 2) = t2_3.b) -(33 rows) +(36 rows) SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM prt1 t1, prt2 t2, prt1_e t3 WHERE t1.a = t2.b AND t1.a = (t3.a + t3.b)/2 AND t1.b = 0 ORDER BY t1.a, t2.b; a | c | b | c | ?column? | c @@ -712,6 +722,7 @@ SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 -> Seq Scan on prt1_e_p1 t3_1 Filter: (c = 0) -> Index Scan using iprt2_p1_b on prt2_p1 t2_1 + Skip scan: All Index Cond: (b = t1_1.a) -> Nested Loop Left Join -> Hash Right Join @@ -721,6 +732,7 @@ SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 -> Seq Scan on prt1_e_p2 t3_2 Filter: (c = 0) -> Index Scan using iprt2_p2_b on prt2_p2 t2_2 + Skip scan: All Index Cond: (b = t1_2.a) -> Nested Loop Left Join -> Hash Right Join @@ -730,8 +742,9 @@ SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 -> Seq Scan on prt1_e_p3 t3_3 Filter: (c = 0) -> Index Scan using iprt2_p3_b on prt2_p3 t2_3 + Skip scan: All Index Cond: (b = t1_3.a) -(30 rows) +(33 rows) SELECT t1.a, t1.c, t2.b, t2.c, t3.a + t3.b, t3.c FROM (prt1 t1 LEFT JOIN prt2 t2 ON t1.a = t2.b) RIGHT JOIN prt1_e t3 ON (t1.a = (t3.a + t3.b)/2) WHERE t3.c = 0 ORDER BY t1.a, t2.b, t3.a + t3.b; a | c | b | c | ?column? | c @@ -826,6 +839,7 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHER -> Seq Scan on prt2_p1 t1_5 Filter: (a = 0) -> Index Scan using iprt1_p1_a on prt1_p1 t1_2 + Skip scan: All Index Cond: (a = ((t2_1.a + t2_1.b) / 2)) Filter: (b = 0) -> Nested Loop @@ -839,6 +853,7 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHER -> Seq Scan on prt2_p2 t1_6 Filter: (a = 0) -> Index Scan using iprt1_p2_a on prt1_p2 t1_3 + Skip scan: All Index Cond: (a = ((t2_2.a + t2_2.b) / 2)) Filter: (b = 0) -> Nested Loop @@ -849,11 +864,13 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHER -> Seq Scan on prt2_p3 t1_7 Filter: (a = 0) -> Index Scan using iprt1_e_p3_ab2 on prt1_e_p3 t2_3 + Skip scan: All Index Cond: (((a + b) / 2) = t1_7.b) -> Index Scan using iprt1_p3_a on prt1_p3 t1_4 + Skip scan: All Index Cond: (a = ((t2_3.a + t2_3.b) / 2)) Filter: (b = 0) -(41 rows) +(45 rows) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1, prt1_e t2 WHERE t1.a = 0 AND t1.b = (t2.a + t2.b)/2) AND t1.b = 0 ORDER BY t1.a; a | b | c @@ -881,6 +898,7 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN ( -> Seq Scan on prt1_e_p1 t1_9 Filter: (c = 0) -> Index Scan using iprt1_p1_a on prt1_p1 t1_3 + Skip scan: All Index Cond: (a = t1_6.b) Filter: (b = 0) -> Nested Loop @@ -893,6 +911,7 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN ( -> Seq Scan on prt1_e_p2 t1_10 Filter: (c = 0) -> Index Scan using iprt1_p2_a on prt1_p2 t1_4 + Skip scan: All Index Cond: (a = t1_7.b) Filter: (b = 0) -> Nested Loop @@ -905,9 +924,10 @@ SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN ( -> Seq Scan on prt1_e_p3 t1_11 Filter: (c = 0) -> Index Scan using iprt1_p3_a on prt1_p3 t1_5 + Skip scan: All Index Cond: (a = t1_8.b) Filter: (b = 0) -(39 rows) +(42 rows) SELECT t1.* FROM prt1 t1 WHERE t1.a IN (SELECT t1.b FROM prt2 t1 WHERE t1.b IN (SELECT (t1.a + t1.b)/2 FROM prt1_e t1 WHERE t1.c = 0)) AND t1.b = 0 ORDER BY t1.a; a | b | c @@ -1933,12 +1953,15 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b); -> Seq Scan on prt1_p3 t1_3 -> Append -> Index Scan using iprt2_p1_b on prt2_p1 t2_1 + Skip scan: All Index Cond: (b > t1.a) -> Index Scan using iprt2_p2_b on prt2_p2 t2_2 + Skip scan: All Index Cond: (b > t1.a) -> Index Scan using iprt2_p3_b on prt2_p3 t2_3 + Skip scan: All Index Cond: (b > t1.a) -(12 rows) +(15 rows) -- equi-join with join condition on partial keys does not qualify for -- partitionwise join diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out index 9c8f80da87..8708a54ada 100644 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@ -2070,24 +2070,33 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on Filter: (a = ANY ('{0,0,1}'::integer[])) -> Append (actual rows=N loops=N) -> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 ab_1 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b2_a_idx on ab_a1_b2 ab_2 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b3_a_idx on ab_a1_b3 ab_3 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b1_a_idx on ab_a2_b1 ab_4 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b2_a_idx on ab_a2_b2 ab_5 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b3_a_idx on ab_a2_b3 ab_6 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b1_a_idx on ab_a3_b1 ab_7 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b2_a_idx on ab_a3_b2 ab_8 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b3_a_idx on ab_a3_b3 ab_9 (never executed) + Skip scan: All Index Cond: (a = a.a) -(27 rows) +(36 rows) -- Ensure the same partitions are pruned when we make the nested loop -- parameter an Expr rather than a plain Param. @@ -2104,24 +2113,33 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on Filter: (a = ANY ('{0,0,1}'::integer[])) -> Append (actual rows=N loops=N) -> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 ab_1 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a1_b2_a_idx on ab_a1_b2 ab_2 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a1_b3_a_idx on ab_a1_b3 ab_3 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a2_b1_a_idx on ab_a2_b1 ab_4 (never executed) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a2_b2_a_idx on ab_a2_b2 ab_5 (never executed) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a2_b3_a_idx on ab_a2_b3 ab_6 (never executed) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a3_b1_a_idx on ab_a3_b1 ab_7 (never executed) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a3_b2_a_idx on ab_a3_b2 ab_8 (never executed) + Skip scan: All Index Cond: (a = (a.a + 0)) -> Index Scan using ab_a3_b3_a_idx on ab_a3_b3 ab_9 (never executed) + Skip scan: All Index Cond: (a = (a.a + 0)) -(27 rows) +(36 rows) insert into lprt_a values(3),(3); select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 3)'); @@ -2137,24 +2155,33 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on Filter: (a = ANY ('{1,0,3}'::integer[])) -> Append (actual rows=N loops=N) -> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 ab_1 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b2_a_idx on ab_a1_b2 ab_2 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b3_a_idx on ab_a1_b3 ab_3 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b1_a_idx on ab_a2_b1 ab_4 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b2_a_idx on ab_a2_b2 ab_5 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b3_a_idx on ab_a2_b3 ab_6 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b1_a_idx on ab_a3_b1 ab_7 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b2_a_idx on ab_a3_b2 ab_8 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b3_a_idx on ab_a3_b3 ab_9 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -(27 rows) +(36 rows) select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 0)'); explain_parallel_append @@ -2170,24 +2197,33 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on Rows Removed by Filter: N -> Append (actual rows=N loops=N) -> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 ab_1 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b2_a_idx on ab_a1_b2 ab_2 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b3_a_idx on ab_a1_b3 ab_3 (actual rows=N loops=N) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b1_a_idx on ab_a2_b1 ab_4 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b2_a_idx on ab_a2_b2 ab_5 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b3_a_idx on ab_a2_b3 ab_6 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b1_a_idx on ab_a3_b1 ab_7 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b2_a_idx on ab_a3_b2 ab_8 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b3_a_idx on ab_a3_b3 ab_9 (never executed) + Skip scan: All Index Cond: (a = a.a) -(28 rows) +(37 rows) delete from lprt_a where a = 1; select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on ab.a = a.a where a.a in(1, 0, 0)'); @@ -2204,24 +2240,33 @@ select explain_parallel_append('select avg(ab.a) from ab inner join lprt_a a on Rows Removed by Filter: N -> Append (actual rows=N loops=N) -> Index Scan using ab_a1_b1_a_idx on ab_a1_b1 ab_1 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b2_a_idx on ab_a1_b2 ab_2 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a1_b3_a_idx on ab_a1_b3 ab_3 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b1_a_idx on ab_a2_b1 ab_4 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b2_a_idx on ab_a2_b2 ab_5 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a2_b3_a_idx on ab_a2_b3 ab_6 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b1_a_idx on ab_a3_b1 ab_7 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b2_a_idx on ab_a3_b2 ab_8 (never executed) + Skip scan: All Index Cond: (a = a.a) -> Index Scan using ab_a3_b3_a_idx on ab_a3_b3 ab_9 (never executed) + Skip scan: All Index Cond: (a = a.a) -(28 rows) +(37 rows) reset enable_hashjoin; reset enable_mergejoin; @@ -2245,48 +2290,57 @@ select * from ab where a = (select max(a) from lprt_a) and b = (select max(a)-1 Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a1_b1_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a1_b2 ab_2 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a1_b2_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a1_b3 ab_3 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a1_b3_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a2_b1 ab_4 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a2_b1_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a2_b2 ab_5 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a2_b2_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a2_b3 ab_6 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a2_b3_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a3_b1 ab_7 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a3_b1_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a3_b2 ab_8 (actual rows=0 loops=1) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a3_b2_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = $0) -> Bitmap Heap Scan on ab_a3_b3 ab_9 (never executed) Recheck Cond: (a = $0) Filter: (b = $1) -> Bitmap Index Scan on ab_a3_b3_a_idx (never executed) + Skip scan: All Index Cond: (a = $0) -(52 rows) +(61 rows) -- Test run-time partition pruning with UNION ALL parents explain (analyze, costs off, summary off, timing off) @@ -2301,16 +2355,19 @@ select * from (select * from ab where a = 1 union all select * from ab) ab where Recheck Cond: (a = 1) Filter: (b = $0) -> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b2 ab_12 (never executed) Recheck Cond: (a = 1) Filter: (b = $0) -> Bitmap Index Scan on ab_a1_b2_a_idx (never executed) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b3 ab_13 (never executed) Recheck Cond: (a = 1) Filter: (b = $0) -> Bitmap Index Scan on ab_a1_b3_a_idx (never executed) + Skip scan: All Index Cond: (a = 1) -> Seq Scan on ab_a1_b1 ab_1 (actual rows=0 loops=1) Filter: (b = $0) @@ -2330,7 +2387,7 @@ select * from (select * from ab where a = 1 union all select * from ab) ab where Filter: (b = $0) -> Seq Scan on ab_a3_b3 ab_9 (never executed) Filter: (b = $0) -(37 rows) +(40 rows) -- A case containing a UNION ALL with a non-partitioned child. explain (analyze, costs off, summary off, timing off) @@ -2345,16 +2402,19 @@ select * from (select * from ab where a = 1 union all (values(10,5)) union all s Recheck Cond: (a = 1) Filter: (b = $0) -> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b2 ab_12 (never executed) Recheck Cond: (a = 1) Filter: (b = $0) -> Bitmap Index Scan on ab_a1_b2_a_idx (never executed) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b3 ab_13 (never executed) Recheck Cond: (a = 1) Filter: (b = $0) -> Bitmap Index Scan on ab_a1_b3_a_idx (never executed) + Skip scan: All Index Cond: (a = 1) -> Result (actual rows=0 loops=1) One-Time Filter: (5 = $0) @@ -2376,7 +2436,7 @@ select * from (select * from ab where a = 1 union all (values(10,5)) union all s Filter: (b = $0) -> Seq Scan on ab_a3_b3 ab_9 (never executed) Filter: (b = $0) -(39 rows) +(42 rows) -- Another UNION ALL test, but containing a mix of exec init and exec run-time pruning. create table xy_1 (x int, y int); @@ -2446,63 +2506,75 @@ update ab_a1 set b = 3 from ab where ab.a = 1 and ab.a = ab_a1.a; -> Bitmap Heap Scan on ab_a1_b1 ab_1 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b2 ab_2 (actual rows=1 loops=1) Recheck Cond: (a = 1) Heap Blocks: exact=1 -> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b3 ab_3 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Materialize (actual rows=0 loops=1) -> Bitmap Heap Scan on ab_a1_b1 ab_a1_1 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Nested Loop (actual rows=1 loops=1) -> Append (actual rows=1 loops=1) -> Bitmap Heap Scan on ab_a1_b1 ab_1 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b2 ab_2 (actual rows=1 loops=1) Recheck Cond: (a = 1) Heap Blocks: exact=1 -> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b3 ab_3 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -> Materialize (actual rows=1 loops=1) -> Bitmap Heap Scan on ab_a1_b2 ab_a1_2 (actual rows=1 loops=1) Recheck Cond: (a = 1) Heap Blocks: exact=1 -> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -> Nested Loop (actual rows=0 loops=1) -> Append (actual rows=1 loops=1) -> Bitmap Heap Scan on ab_a1_b1 ab_1 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b2 ab_2 (actual rows=1 loops=1) Recheck Cond: (a = 1) Heap Blocks: exact=1 -> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -> Bitmap Heap Scan on ab_a1_b3 ab_3 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -> Materialize (actual rows=0 loops=1) -> Bitmap Heap Scan on ab_a1_b3 ab_a1_3 (actual rows=0 loops=1) Recheck Cond: (a = 1) -> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=1 loops=1) + Skip scan: All Index Cond: (a = 1) -(65 rows) +(77 rows) table ab; a | b @@ -2593,18 +2665,24 @@ select * from tbl1 join tprt on tbl1.col1 > tprt.col1; -> Seq Scan on tbl1 (actual rows=2 loops=1) -> Append (actual rows=3 loops=2) -> Index Scan using tprt1_idx on tprt_1 (actual rows=2 loops=2) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt2_idx on tprt_2 (actual rows=2 loops=1) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt3_idx on tprt_3 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt4_idx on tprt_4 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt5_idx on tprt_5 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt6_idx on tprt_6 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -(15 rows) +(21 rows) explain (analyze, costs off, summary off, timing off) select * from tbl1 join tprt on tbl1.col1 = tprt.col1; @@ -2614,18 +2692,24 @@ select * from tbl1 join tprt on tbl1.col1 = tprt.col1; -> Seq Scan on tbl1 (actual rows=2 loops=1) -> Append (actual rows=1 loops=2) -> Index Scan using tprt1_idx on tprt_1 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt2_idx on tprt_2 (actual rows=1 loops=2) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt3_idx on tprt_3 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt4_idx on tprt_4 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt5_idx on tprt_5 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt6_idx on tprt_6 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -(15 rows) +(21 rows) select tbl1.col1, tprt.col1 from tbl1 inner join tprt on tbl1.col1 > tprt.col1 @@ -2659,18 +2743,24 @@ select * from tbl1 inner join tprt on tbl1.col1 > tprt.col1; -> Seq Scan on tbl1 (actual rows=5 loops=1) -> Append (actual rows=5 loops=5) -> Index Scan using tprt1_idx on tprt_1 (actual rows=2 loops=5) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt2_idx on tprt_2 (actual rows=3 loops=4) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt3_idx on tprt_3 (actual rows=1 loops=2) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt4_idx on tprt_4 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt5_idx on tprt_5 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -> Index Scan using tprt6_idx on tprt_6 (never executed) + Skip scan: All Index Cond: (col1 < tbl1.col1) -(15 rows) +(21 rows) explain (analyze, costs off, summary off, timing off) select * from tbl1 inner join tprt on tbl1.col1 = tprt.col1; @@ -2680,18 +2770,24 @@ select * from tbl1 inner join tprt on tbl1.col1 = tprt.col1; -> Seq Scan on tbl1 (actual rows=5 loops=1) -> Append (actual rows=1 loops=5) -> Index Scan using tprt1_idx on tprt_1 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt2_idx on tprt_2 (actual rows=1 loops=2) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt3_idx on tprt_3 (actual rows=0 loops=3) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt4_idx on tprt_4 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt5_idx on tprt_5 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt6_idx on tprt_6 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -(15 rows) +(21 rows) select tbl1.col1, tprt.col1 from tbl1 inner join tprt on tbl1.col1 > tprt.col1 @@ -2744,18 +2840,24 @@ select * from tbl1 join tprt on tbl1.col1 < tprt.col1; -> Seq Scan on tbl1 (actual rows=1 loops=1) -> Append (actual rows=1 loops=1) -> Index Scan using tprt1_idx on tprt_1 (never executed) + Skip scan: All Index Cond: (col1 > tbl1.col1) -> Index Scan using tprt2_idx on tprt_2 (never executed) + Skip scan: All Index Cond: (col1 > tbl1.col1) -> Index Scan using tprt3_idx on tprt_3 (never executed) + Skip scan: All Index Cond: (col1 > tbl1.col1) -> Index Scan using tprt4_idx on tprt_4 (never executed) + Skip scan: All Index Cond: (col1 > tbl1.col1) -> Index Scan using tprt5_idx on tprt_5 (never executed) + Skip scan: All Index Cond: (col1 > tbl1.col1) -> Index Scan using tprt6_idx on tprt_6 (actual rows=1 loops=1) + Skip scan: All Index Cond: (col1 > tbl1.col1) -(15 rows) +(21 rows) select tbl1.col1, tprt.col1 from tbl1 inner join tprt on tbl1.col1 < tprt.col1 @@ -2776,18 +2878,24 @@ select * from tbl1 join tprt on tbl1.col1 = tprt.col1; -> Seq Scan on tbl1 (actual rows=1 loops=1) -> Append (actual rows=0 loops=1) -> Index Scan using tprt1_idx on tprt_1 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt2_idx on tprt_2 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt3_idx on tprt_3 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt4_idx on tprt_4 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt5_idx on tprt_5 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -> Index Scan using tprt6_idx on tprt_6 (never executed) + Skip scan: All Index Cond: (col1 = tbl1.col1) -(15 rows) +(21 rows) select tbl1.col1, tprt.col1 from tbl1 inner join tprt on tbl1.col1 = tprt.col1 @@ -3115,12 +3223,14 @@ explain (analyze, costs off, summary off, timing off) execute mt_q1(15); Sort Key: ma_test.b Subplans Removed: 1 -> Index Scan using ma_test_p2_b_idx on ma_test_p2 ma_test_1 (actual rows=1 loops=1) + Skip scan: All Filter: ((a >= $1) AND ((a % 10) = 5)) Rows Removed by Filter: 9 -> Index Scan using ma_test_p3_b_idx on ma_test_p3 ma_test_2 (actual rows=1 loops=1) + Skip scan: All Filter: ((a >= $1) AND ((a % 10) = 5)) Rows Removed by Filter: 9 -(9 rows) +(11 rows) execute mt_q1(15); a @@ -3136,9 +3246,10 @@ explain (analyze, costs off, summary off, timing off) execute mt_q1(25); Sort Key: ma_test.b Subplans Removed: 2 -> Index Scan using ma_test_p3_b_idx on ma_test_p3 ma_test_1 (actual rows=1 loops=1) + Skip scan: All Filter: ((a >= $1) AND ((a % 10) = 5)) Rows Removed by Filter: 9 -(6 rows) +(7 rows) execute mt_q1(25); a @@ -3185,14 +3296,18 @@ explain (analyze, costs off, summary off, timing off) select * from ma_test wher InitPlan 1 (returns $0) -> Limit (actual rows=1 loops=1) -> Index Scan using ma_test_p2_b_idx on ma_test_p2 (actual rows=1 loops=1) + Skip scan: All Index Cond: (b IS NOT NULL) -> Index Scan using ma_test_p1_b_idx on ma_test_p1 ma_test_1 (never executed) + Skip scan: All Filter: (a >= $1) -> Index Scan using ma_test_p2_b_idx on ma_test_p2 ma_test_2 (actual rows=10 loops=1) + Skip scan: All Filter: (a >= $1) -> Index Scan using ma_test_p3_b_idx on ma_test_p3 ma_test_3 (actual rows=10 loops=1) + Skip scan: All Filter: (a >= $1) -(14 rows) +(18 rows) reset enable_seqscan; reset enable_sort; diff --git a/src/test/regress/expected/plancache.out b/src/test/regress/expected/plancache.out index 7d289b8c5e..2e75bad44d 100644 --- a/src/test/regress/expected/plancache.out +++ b/src/test/regress/expected/plancache.out @@ -290,8 +290,9 @@ explain (costs off) execute test_mode_pp(2); ---------------------------------------------------------- Aggregate -> Index Only Scan using test_mode_a_idx on test_mode + Skip scan: All Index Cond: (a = 2) -(3 rows) +(4 rows) -- force generic plan set plan_cache_mode to force_generic_plan; @@ -351,7 +352,8 @@ explain (costs off) execute test_mode_pp(2); ---------------------------------------------------------- Aggregate -> Index Only Scan using test_mode_a_idx on test_mode + Skip scan: All Index Cond: (a = 2) -(3 rows) +(4 rows) drop table test_mode; diff --git a/src/test/regress/expected/portals.out b/src/test/regress/expected/portals.out index dc0d2ef7dd..5c18de3aa0 100644 --- a/src/test/regress/expected/portals.out +++ b/src/test/regress/expected/portals.out @@ -1253,8 +1253,9 @@ DECLARE c1 CURSOR FOR SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA'; QUERY PLAN --------------------------------------------- Index Only Scan using onek_stringu1 on onek + Skip scan: All Index Cond: (stringu1 = 'DZAAAA'::name) -(2 rows) +(3 rows) DECLARE c1 CURSOR FOR SELECT stringu1 FROM onek WHERE stringu1 = 'DZAAAA'; FETCH FROM c1; diff --git a/src/test/regress/expected/privileges.out b/src/test/regress/expected/privileges.out index c2d037b614..00a113bcd9 100644 --- a/src/test/regress/expected/privileges.out +++ b/src/test/regress/expected/privileges.out @@ -212,9 +212,10 @@ EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b; -> Seq Scan on atest12 atest12_1 Filter: (b <<< 5) -> Index Scan using atest12_a_idx on atest12 + Skip scan: All Index Cond: (a = atest12_1.b) Filter: (b <<< 5) -(6 rows) +(7 rows) -- And this one. EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y @@ -225,8 +226,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM atest12 x, atest12 y -> Seq Scan on atest12 y Filter: (abs(a) <<< 5) -> Index Scan using atest12_a_idx on atest12 x + Skip scan: All Index Cond: (a = y.b) -(5 rows) +(6 rows) -- This should also be a nestloop, but the security barrier forces the inner -- scan to be materialized @@ -261,9 +263,10 @@ EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b; -> Seq Scan on atest12 atest12_1 Filter: (b <<< 5) -> Index Scan using atest12_a_idx on atest12 + Skip scan: All Index Cond: (a = atest12_1.b) Filter: (b <<< 5) -(6 rows) +(7 rows) EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y WHERE x.a = y.b; QUERY PLAN @@ -286,9 +289,10 @@ EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y -> Seq Scan on atest12 atest12_1 Filter: ((b <<< 5) AND (abs(a) <<< 5)) -> Index Scan using atest12_a_idx on atest12 + Skip scan: All Index Cond: (a = atest12_1.b) Filter: (b <<< 5) -(6 rows) +(7 rows) -- But a security barrier view isolates the leaky operator. EXPLAIN (COSTS OFF) SELECT * FROM atest12sbv x, atest12sbv y @@ -317,9 +321,10 @@ EXPLAIN (COSTS OFF) SELECT * FROM atest12v x, atest12v y WHERE x.a = y.b; -> Seq Scan on atest12 atest12_1 Filter: (b <<< 5) -> Index Scan using atest12_a_idx on atest12 + Skip scan: All Index Cond: (a = atest12_1.b) Filter: (b <<< 5) -(6 rows) +(7 rows) -- But not for this, due to lack of table-wide permissions needed -- to make use of the expression index's statistics. diff --git a/src/test/regress/expected/regex.out b/src/test/regress/expected/regex.out index 0923ad9b5b..1cd0fc95fa 100644 --- a/src/test/regress/expected/regex.out +++ b/src/test/regress/expected/regex.out @@ -299,49 +299,55 @@ explain (costs off) select * from pg_proc where proname ~ '^abc'; QUERY PLAN ---------------------------------------------------------------------- Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= 'abc'::text) AND (proname < 'abd'::text)) Filter: (proname ~ '^abc'::text) -(3 rows) +(4 rows) explain (costs off) select * from pg_proc where proname ~ '^abc$'; QUERY PLAN ------------------------------------------------------------ Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: (proname = 'abc'::text) Filter: (proname ~ '^abc$'::text) -(3 rows) +(4 rows) explain (costs off) select * from pg_proc where proname ~ '^abcd*e'; QUERY PLAN ---------------------------------------------------------------------- Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= 'abc'::text) AND (proname < 'abd'::text)) Filter: (proname ~ '^abcd*e'::text) -(3 rows) +(4 rows) explain (costs off) select * from pg_proc where proname ~ '^abc+d'; QUERY PLAN ---------------------------------------------------------------------- Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= 'abc'::text) AND (proname < 'abd'::text)) Filter: (proname ~ '^abc+d'::text) -(3 rows) +(4 rows) explain (costs off) select * from pg_proc where proname ~ '^(abc)(def)'; QUERY PLAN ---------------------------------------------------------------------------- Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= 'abcdef'::text) AND (proname < 'abcdeg'::text)) Filter: (proname ~ '^(abc)(def)'::text) -(3 rows) +(4 rows) explain (costs off) select * from pg_proc where proname ~ '^(abc)$'; QUERY PLAN ------------------------------------------------------------ Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: (proname = 'abc'::text) Filter: (proname ~ '^(abc)$'::text) -(3 rows) +(4 rows) explain (costs off) select * from pg_proc where proname ~ '^(abc)?d'; QUERY PLAN @@ -354,9 +360,10 @@ explain (costs off) select * from pg_proc where proname ~ '^abcd(x|(?=\w\w)q)'; QUERY PLAN ------------------------------------------------------------------------ Index Scan using pg_proc_proname_args_nsp_index on pg_proc + Skip scan: All Index Cond: ((proname >= 'abcd'::text) AND (proname < 'abce'::text)) Filter: (proname ~ '^abcd(x|(?=\w\w)q)'::text) -(3 rows) +(4 rows) -- Test for infinite loop in pullback() (CVE-2007-4772) select 'a' ~ '($|^)*'; diff --git a/src/test/regress/expected/rowsecurity.out b/src/test/regress/expected/rowsecurity.out index 9506aaef82..17d1c916cb 100644 --- a/src/test/regress/expected/rowsecurity.out +++ b/src/test/regress/expected/rowsecurity.out @@ -271,8 +271,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle); Filter: ((dlevel <= $0) AND f_leak(dtitle)) InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -(5 rows) +(6 rows) EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle); QUERY PLAN @@ -281,12 +282,13 @@ EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dt Hash Cond: (category.cid = document.cid) InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -> Seq Scan on category -> Hash -> Seq Scan on document Filter: ((dlevel <= $0) AND f_leak(dtitle)) -(9 rows) +(10 rows) -- viewpoint from regress_rls_dave SET SESSION AUTHORIZATION regress_rls_dave; @@ -335,8 +337,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM document WHERE f_leak(dtitle); Filter: ((cid <> 44) AND (cid <> 44) AND (cid < 50) AND (dlevel <= $0) AND f_leak(dtitle)) InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -(5 rows) +(6 rows) EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dtitle); QUERY PLAN @@ -345,12 +348,13 @@ EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dt Hash Cond: (category.cid = document.cid) InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -> Seq Scan on category -> Hash -> Seq Scan on document Filter: ((cid <> 44) AND (cid <> 44) AND (cid < 50) AND (dlevel <= $0) AND f_leak(dtitle)) -(9 rows) +(10 rows) -- 44 would technically fail for both p2r and p1r, but we should get an error -- back from p1r for this because it sorts first @@ -436,8 +440,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM document NATURAL JOIN category WHERE f_leak(dt -> Seq Scan on document Filter: ((dauthor = CURRENT_USER) AND f_leak(dtitle)) -> Index Scan using category_pkey on category + Skip scan: All Index Cond: (cid = document.cid) -(5 rows) +(6 rows) -- interaction of FK/PK constraints SET SESSION AUTHORIZATION regress_rls_alice; @@ -990,6 +995,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Append InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -> Seq Scan on part_document_fiction part_document_1 Filter: ((dlevel <= $0) AND f_leak(dtitle)) @@ -997,7 +1003,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Filter: ((dlevel <= $0) AND f_leak(dtitle)) -> Seq Scan on part_document_nonfiction part_document_3 Filter: ((dlevel <= $0) AND f_leak(dtitle)) -(10 rows) +(11 rows) -- viewpoint from regress_rls_carol SET SESSION AUTHORIZATION regress_rls_carol; @@ -1032,6 +1038,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Append InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -> Seq Scan on part_document_fiction part_document_1 Filter: ((dlevel <= $0) AND f_leak(dtitle)) @@ -1039,7 +1046,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Filter: ((dlevel <= $0) AND f_leak(dtitle)) -> Seq Scan on part_document_nonfiction part_document_3 Filter: ((dlevel <= $0) AND f_leak(dtitle)) -(10 rows) +(11 rows) -- viewpoint from regress_rls_dave SET SESSION AUTHORIZATION regress_rls_dave; @@ -1063,8 +1070,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Filter: ((cid < 55) AND (dlevel <= $0) AND f_leak(dtitle)) InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -(5 rows) +(6 rows) -- pp1 ERROR INSERT INTO part_document VALUES (100, 11, 5, 'regress_rls_dave', 'testing pp1'); -- fail @@ -1141,8 +1149,9 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Filter: ((cid < 55) AND (dlevel <= $0) AND f_leak(dtitle)) InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -(5 rows) +(6 rows) -- viewpoint from regress_rls_carol SET SESSION AUTHORIZATION regress_rls_carol; @@ -1179,6 +1188,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Append InitPlan 1 (returns $0) -> Index Scan using uaccount_pkey on uaccount + Skip scan: All Index Cond: (pguser = CURRENT_USER) -> Seq Scan on part_document_fiction part_document_1 Filter: ((dlevel <= $0) AND f_leak(dtitle)) @@ -1186,7 +1196,7 @@ EXPLAIN (COSTS OFF) SELECT * FROM part_document WHERE f_leak(dtitle); Filter: ((dlevel <= $0) AND f_leak(dtitle)) -> Seq Scan on part_document_nonfiction part_document_3 Filter: ((dlevel <= $0) AND f_leak(dtitle)) -(10 rows) +(11 rows) -- only owner can change policies ALTER POLICY pp1 ON part_document USING (true); --fail diff --git a/src/test/regress/expected/rowtypes.out b/src/test/regress/expected/rowtypes.out index 2a273f8404..4d58053e4f 100644 --- a/src/test/regress/expected/rowtypes.out +++ b/src/test/regress/expected/rowtypes.out @@ -259,8 +259,9 @@ order by thousand, tenthous; QUERY PLAN ----------------------------------------------------------- Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: (ROW(thousand, tenthous) >= ROW(997, 5000)) -(2 rows) +(3 rows) select thousand, tenthous from tenk1 where (thousand, tenthous) >= (997, 5000) @@ -305,8 +306,9 @@ order by thousand, tenthous; -> Bitmap Heap Scan on tenk1 Filter: (ROW(thousand, tenthous, four) > ROW(998, 5000, 3)) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (ROW(thousand, tenthous) >= ROW(998, 5000)) -(6 rows) +(7 rows) select thousand, tenthous, four from tenk1 where (thousand, tenthous, four) > (998, 5000, 3) @@ -337,8 +339,9 @@ order by thousand, tenthous; QUERY PLAN ---------------------------------------------------------- Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: (ROW(thousand, tenthous) > ROW(998, 5000)) -(2 rows) +(3 rows) select thousand, tenthous from tenk1 where (998, 5000) < (thousand, tenthous) @@ -373,8 +376,9 @@ order by thousand, hundred; -> Bitmap Heap Scan on tenk1 Filter: (ROW(998, 5000) < ROW(thousand, hundred)) -> Bitmap Index Scan on tenk1_thous_tenthous + Skip scan: All Index Cond: (thousand >= 998) -(6 rows) +(7 rows) select thousand, hundred from tenk1 where (998, 5000) < (thousand, hundred) @@ -405,8 +409,9 @@ select a,b from test_table where (a,b) > ('a','a') order by a,b; QUERY PLAN -------------------------------------------------------- Index Only Scan using test_table_a_b_idx on test_table + Skip scan: All Index Cond: (ROW(a, b) > ROW('a'::text, 'a'::text)) -(2 rows) +(3 rows) select a,b from test_table where (a,b) > ('a','a') order by a,b; a | b @@ -1109,8 +1114,9 @@ select row_to_json(q) from ------------------------------------------------------------- Subquery Scan on q -> Index Only Scan using tenk1_thous_tenthous on tenk1 + Skip scan: All Index Cond: ((thousand = 42) AND (tenthous < 2000)) -(3 rows) +(4 rows) select row_to_json(q) from (select thousand, tenthous from tenk1 diff --git a/src/test/regress/expected/select.out b/src/test/regress/expected/select.out index c441049f41..dd7c4117ed 100644 --- a/src/test/regress/expected/select.out +++ b/src/test/regress/expected/select.out @@ -742,9 +742,10 @@ select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; QUERY PLAN ----------------------------------------- Index Scan using onek2_u2_prtl on onek2 + Skip scan: All Index Cond: (unique2 = 11) Filter: (stringu1 = 'ATAAAA'::name) -(3 rows) +(4 rows) select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 @@ -758,18 +759,20 @@ select * from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; QUERY PLAN ----------------------------------------------------------------- Index Scan using onek2_u2_prtl on onek2 (actual rows=1 loops=1) + Skip scan: All Index Cond: (unique2 = 11) Filter: (stringu1 = 'ATAAAA'::name) -(3 rows) +(4 rows) explain (costs off) select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; QUERY PLAN ----------------------------------------- Index Scan using onek2_u2_prtl on onek2 + Skip scan: All Index Cond: (unique2 = 11) Filter: (stringu1 = 'ATAAAA'::name) -(3 rows) +(4 rows) select unique2 from onek2 where unique2 = 11 and stringu1 = 'ATAAAA'; unique2 @@ -783,8 +786,9 @@ select * from onek2 where unique2 = 11 and stringu1 < 'B'; QUERY PLAN ----------------------------------------- Index Scan using onek2_u2_prtl on onek2 + Skip scan: All Index Cond: (unique2 = 11) -(2 rows) +(3 rows) select * from onek2 where unique2 = 11 and stringu1 < 'B'; unique1 | unique2 | two | four | ten | twenty | hundred | thousand | twothousand | fivethous | tenthous | odd | even | stringu1 | stringu2 | string4 @@ -797,8 +801,9 @@ select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; QUERY PLAN ---------------------------------------------- Index Only Scan using onek2_u2_prtl on onek2 + Skip scan: All Index Cond: (unique2 = 11) -(2 rows) +(3 rows) select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; unique2 @@ -813,9 +818,10 @@ select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update; ----------------------------------------------- LockRows -> Index Scan using onek2_u2_prtl on onek2 + Skip scan: All Index Cond: (unique2 = 11) Filter: (stringu1 < 'B'::name) -(4 rows) +(5 rows) select unique2 from onek2 where unique2 = 11 and stringu1 < 'B' for update; unique2 @@ -847,8 +853,9 @@ select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; Bitmap Heap Scan on onek2 Recheck Cond: ((unique2 = 11) AND (stringu1 < 'B'::name)) -> Bitmap Index Scan on onek2_u2_prtl + Skip scan: All Index Cond: (unique2 = 11) -(4 rows) +(5 rows) select unique2 from onek2 where unique2 = 11 and stringu1 < 'B'; unique2 @@ -868,10 +875,12 @@ select unique1, unique2 from onek2 Filter: (stringu1 < 'B'::name) -> BitmapOr -> Bitmap Index Scan on onek2_u2_prtl + Skip scan: All Index Cond: (unique2 = 11) -> Bitmap Index Scan on onek2_u1_prtl + Skip scan: All Index Cond: (unique1 = 0) -(8 rows) +(10 rows) select unique1, unique2 from onek2 where (unique2 = 11 or unique1 = 0) and stringu1 < 'B'; @@ -890,10 +899,12 @@ select unique1, unique2 from onek2 Recheck Cond: (((unique2 = 11) AND (stringu1 < 'B'::name)) OR (unique1 = 0)) -> BitmapOr -> Bitmap Index Scan on onek2_u2_prtl + Skip scan: All Index Cond: (unique2 = 11) -> Bitmap Index Scan on onek2_u1_prtl + Skip scan: All Index Cond: (unique1 = 0) -(7 rows) +(9 rows) select unique1, unique2 from onek2 where (unique2 = 11 and stringu1 < 'B') or unique1 = 0; diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out index e21afa7990..076c3d571d 100644 --- a/src/test/regress/expected/select_distinct.out +++ b/src/test/regress/expected/select_distinct.out @@ -395,18 +395,18 @@ SELECT DISTINCT on (a, b) a, b FROM distinct_a WHERE b = 2; EXPLAIN (COSTS OFF) SELECT DISTINCT a FROM distinct_a WHERE b = 2; - QUERY PLAN ----------------------------------------------------- - Index Only Scan using distinct_a_b_a on distinct_a + QUERY PLAN +-------------------------------------------------------- + Index Only Scan using distinct_a_a_b_idx on distinct_a Skip scan: Distinct only Index Cond: (b = 2) (3 rows) EXPLAIN (COSTS OFF) SELECT DISTINCT on (a, b) a, b FROM distinct_a WHERE b = 2; - QUERY PLAN ----------------------------------------------------- - Index Only Scan using distinct_a_b_a on distinct_a + QUERY PLAN +-------------------------------------------------------- + Index Only Scan using distinct_a_a_b_idx on distinct_a Skip scan: Distinct only Index Cond: (b = 2) (3 rows) @@ -633,8 +633,9 @@ FROM distinct_a WHERE a = 1 ORDER BY a; -> Bitmap Heap Scan on distinct_a Recheck Cond: (a = 1) -> Bitmap Index Scan on distinct_a_a_b_idx + Skip scan: All Index Cond: (a = 1) -(5 rows) +(6 rows) -- check colums order SELECT DISTINCT a FROM distinct_a WHERE b = 2 AND c = 10; diff --git a/src/test/regress/expected/select_parallel.out b/src/test/regress/expected/select_parallel.out index 96dfb7c8dd..5e6377f258 100644 --- a/src/test/regress/expected/select_parallel.out +++ b/src/test/regress/expected/select_parallel.out @@ -523,8 +523,9 @@ explain (costs off) -> Parallel Bitmap Heap Scan on tenk1 Recheck Cond: (hundred > 1) -> Bitmap Index Scan on tenk1_hundred + Skip scan: All Index Cond: (hundred > 1) -(10 rows) +(11 rows) select count(*) from tenk1, tenk2 where tenk1.hundred > 1 and tenk2.thousand=0; count @@ -621,7 +622,8 @@ explain (costs off) Merge Cond: (tenk1.unique1 = tenk2.unique1) -> Parallel Index Only Scan using tenk1_unique1 on tenk1 -> Index Only Scan using tenk2_unique1 on tenk2 -(8 rows) + Skip scan: All +(9 rows) select count(*) from tenk1, tenk2 where tenk1.unique1 = tenk2.unique1; count @@ -949,8 +951,9 @@ explain (costs off) Workers Planned: 1 Single Copy: true -> Index Scan using tenk1_unique1 on tenk1 + Skip scan: All Index Cond: (unique1 = 1) -(5 rows) +(6 rows) ROLLBACK TO SAVEPOINT settings; -- exercise record typmod remapping between backends diff --git a/src/test/regress/expected/subselect.out b/src/test/regress/expected/subselect.out index 4c6cd5f146..7334413144 100644 --- a/src/test/regress/expected/subselect.out +++ b/src/test/regress/expected/subselect.out @@ -895,12 +895,13 @@ where o.ten = 0; Filter: (o.ten = 0) -> Index Scan using onek_unique1 on public.onek i Output: (hashed SubPlan 1), random() + Skip scan: All Index Cond: (i.unique1 = o.unique1) SubPlan 1 -> Seq Scan on public.int4_tbl Output: int4_tbl.f1 Filter: (int4_tbl.f1 <= $0) -(14 rows) +(15 rows) select sum(ss.tst::int) from onek o cross join lateral ( @@ -935,11 +936,13 @@ where o.ten = 1; -> Append -> Subquery Scan on "*SELECT* 1" -> Index Scan using onek_unique1 on onek i1 + Skip scan: All Index Cond: (unique1 = o.unique1) -> Subquery Scan on "*SELECT* 2" -> Index Scan using onek_unique1 on onek i2 + Skip scan: All Index Cond: (unique1 = o.unique2) -(13 rows) +(15 rows) select count(*) from onek o cross join lateral ( @@ -1095,7 +1098,8 @@ select * from int4_tbl where SubPlan 1 -> Index Only Scan using tenk1_unique1 on public.tenk1 a Output: a.unique1 -(10 rows) + Skip scan: All +(11 rows) select * from int4_tbl where (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in diff --git a/src/test/regress/expected/tuplesort.out b/src/test/regress/expected/tuplesort.out index 3fc1998bf2..f47744d2fe 100644 --- a/src/test/regress/expected/tuplesort.out +++ b/src/test/regress/expected/tuplesort.out @@ -146,7 +146,8 @@ SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER ----------------------------------------------------------------------------------------- Limit -> Index Scan using abbrev_abort_uuids__noabort_increasing_idx on abbrev_abort_uuids -(2 rows) + Skip scan: All +(3 rows) SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_increasing LIMIT 5; id | noabort_increasing | noabort_decreasing @@ -164,7 +165,8 @@ SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER ----------------------------------------------------------------------------------------- Limit -> Index Scan using abbrev_abort_uuids__noabort_decreasing_idx on abbrev_abort_uuids -(2 rows) + Skip scan: All +(3 rows) SELECT id, noabort_increasing, noabort_decreasing FROM abbrev_abort_uuids ORDER BY noabort_decreasing LIMIT 5; id | noabort_increasing | noabort_decreasing @@ -186,7 +188,8 @@ SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY a --------------------------------------------------------------------------------------- Limit -> Index Scan using abbrev_abort_uuids__abort_increasing_idx on abbrev_abort_uuids -(2 rows) + Skip scan: All +(3 rows) SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_increasing LIMIT 5; id | abort_increasing | abort_decreasing @@ -204,7 +207,8 @@ SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY a --------------------------------------------------------------------------------------- Limit -> Index Scan using abbrev_abort_uuids__abort_decreasing_idx on abbrev_abort_uuids -(2 rows) + Skip scan: All +(3 rows) SELECT id, abort_increasing, abort_decreasing FROM abbrev_abort_uuids ORDER BY abort_decreasing LIMIT 5; id | abort_increasing | abort_decreasing diff --git a/src/test/regress/expected/union.out b/src/test/regress/expected/union.out index 6e72e92d80..1739a87d46 100644 --- a/src/test/regress/expected/union.out +++ b/src/test/regress/expected/union.out @@ -360,7 +360,8 @@ select count(*) from -> Seq Scan on tenk1 -> Subquery Scan on "*SELECT* 1" -> Index Only Scan using tenk1_unique1 on tenk1 tenk1_1 -(8 rows) + Skip scan: All +(9 rows) select count(*) from ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss; @@ -377,10 +378,12 @@ select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10; -> Append -> Subquery Scan on "*SELECT* 1" -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All -> Subquery Scan on "*SELECT* 2" -> Index Only Scan using tenk1_unique2 on tenk1 tenk1_1 + Skip scan: All Filter: (unique2 <> 10) -(7 rows) +(9 rows) select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10; unique1 @@ -404,7 +407,8 @@ select count(*) from -> Seq Scan on tenk1 -> Subquery Scan on "*SELECT* 1" -> Index Only Scan using tenk1_unique1 on tenk1 tenk1_1 -(10 rows) + Skip scan: All +(11 rows) select count(*) from ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss; @@ -423,10 +427,12 @@ select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10; -> Append -> Subquery Scan on "*SELECT* 1" -> Index Only Scan using tenk1_unique1 on tenk1 + Skip scan: All -> Subquery Scan on "*SELECT* 2" -> Index Only Scan using tenk1_unique2 on tenk1 tenk1_1 + Skip scan: All Filter: (unique2 <> 10) -(9 rows) +(11 rows) select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10; unique1 @@ -711,10 +717,12 @@ explain (costs off) --------------------------------------------- Append -> Index Scan using t1_ab_idx on t1 + Skip scan: All Index Cond: ((a || b) = 'ab'::text) -> Index Only Scan using t2_pkey on t2 + Skip scan: All Index Cond: (ab = 'ab'::text) -(5 rows) +(7 rows) explain (costs off) SELECT * FROM @@ -728,10 +736,12 @@ explain (costs off) Group Key: ((t1.a || t1.b)) -> Append -> Index Scan using t1_ab_idx on t1 + Skip scan: All Index Cond: ((a || b) = 'ab'::text) -> Index Only Scan using t2_pkey on t2 + Skip scan: All Index Cond: (ab = 'ab'::text) -(7 rows) +(9 rows) -- -- Test that ORDER BY for UNION ALL can be pushed down to inheritance @@ -757,10 +767,14 @@ explain (costs off) -> Merge Append Sort Key: ((t1.a || t1.b)) -> Index Scan using t1_ab_idx on t1 + Skip scan: All -> Index Scan using t1c_ab_idx on t1c t1_1 + Skip scan: All -> Index Scan using t2_pkey on t2 + Skip scan: All -> Index Scan using t2c_pkey on t2c t2_1 -(7 rows) + Skip scan: All +(11 rows) SELECT * FROM (SELECT a || b AS ab FROM t1 @@ -797,11 +811,13 @@ select event_id Merge Append Sort Key: events.event_id -> Index Scan using events_pkey on events + Skip scan: All -> Sort Sort Key: events_1.event_id -> Seq Scan on events_child events_1 -> Index Scan using other_events_pkey on other_events -(7 rows) + Skip scan: All +(9 rows) drop table events_child, events, other_events; reset enable_indexonlyscan; @@ -1006,10 +1022,12 @@ select * from -> Seq Scan on int4_tbl -> Append -> Index Scan using t3i on t3 a + Skip scan: All Index Cond: (expensivefunc(x) = int4_tbl.f1) -> Index Scan using t3i on t3 b + Skip scan: All Index Cond: (expensivefunc(x) = int4_tbl.f1) -(7 rows) +(9 rows) select * from (select * from t3 a union all select * from t3 b) ss diff --git a/src/test/regress/expected/updatable_views.out b/src/test/regress/expected/updatable_views.out index 5de53f2782..3b0d9d42bf 100644 --- a/src/test/regress/expected/updatable_views.out +++ b/src/test/regress/expected/updatable_views.out @@ -422,16 +422,18 @@ EXPLAIN (costs off) UPDATE rw_view1 SET a=6 WHERE a=5; -------------------------------------------------- Update on base_tbl -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: ((a > 0) AND (a = 5)) -(3 rows) +(4 rows) EXPLAIN (costs off) DELETE FROM rw_view1 WHERE a=5; QUERY PLAN -------------------------------------------------- Delete on base_tbl -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: ((a > 0) AND (a = 5)) -(3 rows) +(4 rows) DROP TABLE base_tbl CASCADE; NOTICE: drop cascades to view rw_view1 @@ -492,16 +494,18 @@ EXPLAIN (costs off) UPDATE rw_view2 SET aaa=5 WHERE aaa=4; -------------------------------------------------------- Update on base_tbl -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: ((a < 10) AND (a > 0) AND (a = 4)) -(3 rows) +(4 rows) EXPLAIN (costs off) DELETE FROM rw_view2 WHERE aaa=4; QUERY PLAN -------------------------------------------------------- Delete on base_tbl -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: ((a < 10) AND (a > 0) AND (a = 4)) -(3 rows) +(4 rows) DROP TABLE base_tbl CASCADE; NOTICE: drop cascades to 2 other objects @@ -685,14 +689,16 @@ EXPLAIN (costs off) UPDATE rw_view2 SET a=3 WHERE a=2; Update on base_tbl -> Nested Loop -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: (a = 2) -> Subquery Scan on rw_view1 Filter: ((rw_view1.a < 10) AND (rw_view1.a = 2)) -> Bitmap Heap Scan on base_tbl base_tbl_1 Recheck Cond: (a > 0) -> Bitmap Index Scan on base_tbl_pkey + Skip scan: All Index Cond: (a > 0) -(10 rows) +(12 rows) EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2; QUERY PLAN @@ -700,14 +706,16 @@ EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2; Delete on base_tbl -> Nested Loop -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: (a = 2) -> Subquery Scan on rw_view1 Filter: ((rw_view1.a < 10) AND (rw_view1.a = 2)) -> Bitmap Heap Scan on base_tbl base_tbl_1 Recheck Cond: (a > 0) -> Bitmap Index Scan on base_tbl_pkey + Skip scan: All Index Cond: (a > 0) -(10 rows) +(12 rows) DROP TABLE base_tbl CASCADE; NOTICE: drop cascades to 2 other objects @@ -919,8 +927,9 @@ EXPLAIN (costs off) UPDATE rw_view2 SET a=3 WHERE a=2; -> Bitmap Heap Scan on base_tbl Recheck Cond: (a > 0) -> Bitmap Index Scan on base_tbl_pkey + Skip scan: All Index Cond: (a > 0) -(7 rows) +(8 rows) EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2; QUERY PLAN @@ -931,8 +940,9 @@ EXPLAIN (costs off) DELETE FROM rw_view2 WHERE a=2; -> Bitmap Heap Scan on base_tbl Recheck Cond: (a > 0) -> Bitmap Index Scan on base_tbl_pkey + Skip scan: All Index Cond: (a > 0) -(7 rows) +(8 rows) DROP TABLE base_tbl CASCADE; NOTICE: drop cascades to 2 other objects @@ -969,8 +979,9 @@ UPDATE rw_view1 v SET bb='Updated row 2' WHERE rw_view1_aa(v)=2 -------------------------------------------------- Update on base_tbl -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: (a = 2) -(3 rows) +(4 rows) DROP TABLE base_tbl CASCADE; NOTICE: drop cascades to 2 other objects @@ -1868,10 +1879,11 @@ EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (5); -> Result SubPlan 1 -> Index Only Scan using ref_tbl_pkey on ref_tbl r + Skip scan: All Index Cond: (a = b.a) SubPlan 2 -> Seq Scan on ref_tbl r_1 -(7 rows) +(8 rows) EXPLAIN (costs off) UPDATE rw_view1 SET a = a + 5; QUERY PLAN @@ -1884,10 +1896,11 @@ EXPLAIN (costs off) UPDATE rw_view1 SET a = a + 5; -> Seq Scan on ref_tbl r SubPlan 1 -> Index Only Scan using ref_tbl_pkey on ref_tbl r_1 + Skip scan: All Index Cond: (a = b.a) SubPlan 2 -> Seq Scan on ref_tbl r_2 -(11 rows) +(12 rows) DROP TABLE base_tbl, ref_tbl CASCADE; NOTICE: drop cascades to view rw_view1 @@ -2219,11 +2232,13 @@ EXPLAIN (costs off) DELETE FROM rw_view1 WHERE id = 1 AND snoop(data); Update on base_tbl base_tbl_1 -> Nested Loop -> Index Scan using base_tbl_pkey on base_tbl base_tbl_1 + Skip scan: All Index Cond: (id = 1) -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: (id = 1) Filter: ((NOT deleted) AND snoop(data)) -(7 rows) +(9 rows) DELETE FROM rw_view1 WHERE id = 1 AND snoop(data); NOTICE: snooped value: Row 1 @@ -2233,6 +2248,7 @@ EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (2, 'New row 2'); Insert on base_tbl InitPlan 1 (returns $0) -> Index Only Scan using base_tbl_pkey on base_tbl t + Skip scan: All Index Cond: (id = 2) -> Result One-Time Filter: ($0 IS NOT TRUE) @@ -2240,12 +2256,14 @@ EXPLAIN (costs off) INSERT INTO rw_view1 VALUES (2, 'New row 2'); Update on base_tbl InitPlan 1 (returns $0) -> Index Only Scan using base_tbl_pkey on base_tbl t + Skip scan: All Index Cond: (id = 2) -> Result One-Time Filter: $0 -> Index Scan using base_tbl_pkey on base_tbl + Skip scan: All Index Cond: (id = 2) -(15 rows) +(18 rows) INSERT INTO rw_view1 VALUES (2, 'New row 2'); SELECT * FROM base_tbl; @@ -2310,6 +2328,7 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6; Update on public.t111 t1_3 -> Index Scan using t1_a_idx on public.t1 Output: 100, t1.b, t1.c, t1.ctid + Skip scan: All Index Cond: ((t1.a > 5) AND (t1.a < 7)) Filter: ((t1.a <> 6) AND (alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1.a) AND leakproof(t1.a)) SubPlan 1 @@ -2326,17 +2345,20 @@ UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6; Output: t12_5.a -> Index Scan using t11_a_idx on public.t11 t1_1 Output: 100, t1_1.b, t1_1.c, t1_1.d, t1_1.ctid + Skip scan: All Index Cond: ((t1_1.a > 5) AND (t1_1.a < 7)) Filter: ((t1_1.a <> 6) AND (alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1_1.a) AND leakproof(t1_1.a)) -> Index Scan using t12_a_idx on public.t12 t1_2 Output: 100, t1_2.b, t1_2.c, t1_2.e, t1_2.ctid + Skip scan: All Index Cond: ((t1_2.a > 5) AND (t1_2.a < 7)) Filter: ((t1_2.a <> 6) AND (alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1_2.a) AND leakproof(t1_2.a)) -> Index Scan using t111_a_idx on public.t111 t1_3 Output: 100, t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid + Skip scan: All Index Cond: ((t1_3.a > 5) AND (t1_3.a < 7)) Filter: ((t1_3.a <> 6) AND (alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1_3.a) AND leakproof(t1_3.a)) -(33 rows) +(37 rows) UPDATE v1 SET a=100 WHERE snoop(a) AND leakproof(a) AND a < 7 AND a != 6; SELECT * FROM v1 WHERE a=100; -- Nothing should have been changed to 100 @@ -2360,6 +2382,7 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8; Update on public.t111 t1_3 -> Index Scan using t1_a_idx on public.t1 Output: (t1.a + 1), t1.b, t1.c, t1.ctid + Skip scan: All Index Cond: ((t1.a > 5) AND (t1.a = 8)) Filter: ((alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1.a) AND leakproof(t1.a)) SubPlan 1 @@ -2376,17 +2399,20 @@ UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8; Output: t12_5.a -> Index Scan using t11_a_idx on public.t11 t1_1 Output: (t1_1.a + 1), t1_1.b, t1_1.c, t1_1.d, t1_1.ctid + Skip scan: All Index Cond: ((t1_1.a > 5) AND (t1_1.a = 8)) Filter: ((alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1_1.a) AND leakproof(t1_1.a)) -> Index Scan using t12_a_idx on public.t12 t1_2 Output: (t1_2.a + 1), t1_2.b, t1_2.c, t1_2.e, t1_2.ctid + Skip scan: All Index Cond: ((t1_2.a > 5) AND (t1_2.a = 8)) Filter: ((alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1_2.a) AND leakproof(t1_2.a)) -> Index Scan using t111_a_idx on public.t111 t1_3 Output: (t1_3.a + 1), t1_3.b, t1_3.c, t1_3.d, t1_3.e, t1_3.ctid + Skip scan: All Index Cond: ((t1_3.a > 5) AND (t1_3.a = 8)) Filter: ((alternatives: SubPlan 1 or hashed SubPlan 2) AND snoop(t1_3.a) AND leakproof(t1_3.a)) -(33 rows) +(37 rows) UPDATE v1 SET a=a+1 WHERE snoop(a) AND leakproof(a) AND a = 8; NOTICE: snooped value: 8 -- 2.25.0