mirror of
https://github.com/postgres/postgres.git
synced 2025-05-18 17:41:14 +03:00
Try to stabilize flappy test result.
This recently-added test case checks the plan of an inner join between two identical tables. It's just chance which join order the planner will pick, and in the presence of any variation in the underlying statistics, the displayed plan might change. Add a WHERE condition to break the cost symmetry and hopefully stabilize matters. (We're still trying to understand exactly why the underlying statistics aren't as stable as intended, but this seems like a good change anyway, since this test would surely bite us again in future.) While here, clean up assorted comment spelling, grammar, and whitespace problems. Discussion: https://postgr.es/m/4168116.1711720146@sss.pgh.pa.us
This commit is contained in:
parent
d3ae2a24f2
commit
c2df2ed90a
@ -1977,7 +1977,7 @@ select * from x for update;
|
|||||||
Output: subselect_tbl.f1, subselect_tbl.f2, subselect_tbl.f3
|
Output: subselect_tbl.f1, subselect_tbl.f2, subselect_tbl.f3
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
-- Pull-up the direct-correlated ANY_SUBLINK
|
-- Pull up direct-correlated ANY_SUBLINKs
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select * from tenk1 A where hundred in (select hundred from tenk2 B where B.odd = A.odd);
|
select * from tenk1 A where hundred in (select hundred from tenk2 B where B.odd = A.odd);
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
@ -2009,7 +2009,7 @@ WHERE c.odd = b.odd));
|
|||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
-- we should only try to pull up the sublink into RHS of a left join
|
-- we should only try to pull up the sublink into RHS of a left join
|
||||||
-- but a.hundred is not avaiable.
|
-- but a.hundred is not available.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
||||||
@ -2026,7 +2026,7 @@ ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
|||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
-- we should only try to pull up the sublink into RHS of a left join
|
-- we should only try to pull up the sublink into RHS of a left join
|
||||||
-- but a.odd is not avaiable for this.
|
-- but a.odd is not available for this.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd);
|
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd);
|
||||||
@ -2042,7 +2042,7 @@ ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd);
|
|||||||
Filter: (odd = a.odd)
|
Filter: (odd = a.odd)
|
||||||
(8 rows)
|
(8 rows)
|
||||||
|
|
||||||
-- should be able to pull up since all the references is available
|
-- should be able to pull up since all the references are available.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
||||||
@ -2063,7 +2063,8 @@ ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
|||||||
-- we can pull up the sublink into the inner JoinExpr.
|
-- we can pull up the sublink into the inner JoinExpr.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A INNER JOIN tenk2 B
|
SELECT * FROM tenk1 A INNER JOIN tenk2 B
|
||||||
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd)
|
||||||
|
WHERE a.thousand < 750;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
Hash Join
|
Hash Join
|
||||||
@ -2071,13 +2072,14 @@ ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
|||||||
-> Hash Join
|
-> Hash Join
|
||||||
Hash Cond: (a.hundred = c.hundred)
|
Hash Cond: (a.hundred = c.hundred)
|
||||||
-> Seq Scan on tenk1 a
|
-> Seq Scan on tenk1 a
|
||||||
|
Filter: (thousand < 750)
|
||||||
-> Hash
|
-> Hash
|
||||||
-> HashAggregate
|
-> HashAggregate
|
||||||
Group Key: c.odd, c.hundred
|
Group Key: c.odd, c.hundred
|
||||||
-> Seq Scan on tenk2 c
|
-> Seq Scan on tenk2 c
|
||||||
-> Hash
|
-> Hash
|
||||||
-> Seq Scan on tenk2 b
|
-> Seq Scan on tenk2 b
|
||||||
(11 rows)
|
(12 rows)
|
||||||
|
|
||||||
-- we can pull up the aggregate sublink into RHS of a left join.
|
-- we can pull up the aggregate sublink into RHS of a left join.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
|
@ -983,7 +983,7 @@ explain (verbose, costs off)
|
|||||||
with x as (select * from subselect_tbl)
|
with x as (select * from subselect_tbl)
|
||||||
select * from x for update;
|
select * from x for update;
|
||||||
|
|
||||||
-- Pull-up the direct-correlated ANY_SUBLINK
|
-- Pull up direct-correlated ANY_SUBLINKs
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
select * from tenk1 A where hundred in (select hundred from tenk2 B where B.odd = A.odd);
|
select * from tenk1 A where hundred in (select hundred from tenk2 B where B.odd = A.odd);
|
||||||
|
|
||||||
@ -994,18 +994,18 @@ where A.hundred in (select C.hundred FROM tenk2 C
|
|||||||
WHERE c.odd = b.odd));
|
WHERE c.odd = b.odd));
|
||||||
|
|
||||||
-- we should only try to pull up the sublink into RHS of a left join
|
-- we should only try to pull up the sublink into RHS of a left join
|
||||||
-- but a.hundred is not avaiable.
|
-- but a.hundred is not available.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
||||||
|
|
||||||
-- we should only try to pull up the sublink into RHS of a left join
|
-- we should only try to pull up the sublink into RHS of a left join
|
||||||
-- but a.odd is not avaiable for this.
|
-- but a.odd is not available for this.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd);
|
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = a.odd);
|
||||||
|
|
||||||
-- should be able to pull up since all the references is available
|
-- should be able to pull up since all the references are available.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
||||||
@ -1013,9 +1013,10 @@ ON B.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
|||||||
-- we can pull up the sublink into the inner JoinExpr.
|
-- we can pull up the sublink into the inner JoinExpr.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A INNER JOIN tenk2 B
|
SELECT * FROM tenk1 A INNER JOIN tenk2 B
|
||||||
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd);
|
ON A.hundred in (SELECT c.hundred FROM tenk2 C WHERE c.odd = b.odd)
|
||||||
|
WHERE a.thousand < 750;
|
||||||
|
|
||||||
-- we can pull up the aggregate sublink into RHS of a left join.
|
-- we can pull up the aggregate sublink into RHS of a left join.
|
||||||
explain (costs off)
|
explain (costs off)
|
||||||
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
SELECT * FROM tenk1 A LEFT JOIN tenk2 B
|
||||||
ON B.hundred in (SELECT min(c.hundred) FROM tenk2 C WHERE c.odd = b.odd);
|
ON B.hundred in (SELECT min(c.hundred) FROM tenk2 C WHERE c.odd = b.odd);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user