@@ -1867,33 +1867,6 @@ SELECT '' AS "xxx", *
18671867 | 1 | 4 | one | -1
18681868(1 row)
18691869
1870- --
1871- -- semijoin selectivity for <>
1872- --
1873- explain (costs off)
1874- select * from int4_tbl i4, tenk1 a
1875- where exists(select * from tenk1 b
1876- where a.twothousand = b.twothousand and a.fivethous <> b.fivethous)
1877- and i4.f1 = a.tenthous;
1878- QUERY PLAN
1879- -----------------------------------------------------------------------
1880- Remote Subquery Scan on all (datanode_1,datanode_2)
1881- -> Hash Semi Join
1882- Hash Cond: (a.twothousand = b.twothousand)
1883- Join Filter: (a.fivethous <> b.fivethous)
1884- -> Remote Subquery Scan on all (datanode_1,datanode_2)
1885- Distribute results by H: twothousand
1886- -> Hash Join
1887- Hash Cond: (a.tenthous = i4.f1)
1888- -> Seq Scan on tenk1 a
1889- -> Hash
1890- -> Seq Scan on int4_tbl i4
1891- -> Hash
1892- -> Remote Subquery Scan on all (datanode_1,datanode_2)
1893- Distribute results by H: twothousand
1894- -> Seq Scan on tenk1 b
1895- (15 rows)
1896-
18971870--
18981871-- More complicated constructs
18991872--
@@ -2447,7 +2420,7 @@ select count(*) from tenk1 a, tenk1 b
24472420 -> Partial Aggregate
24482421 -> Hash Join
24492422 Hash Cond: (a.hundred = b.thousand)
2450- -> Seq Scan on tenk1 a
2423+ -> Index Only Scan using tenk1_hundred on tenk1 a
24512424 -> Hash
24522425 -> Remote Subquery Scan on all (datanode_1,datanode_2)
24532426 -> Seq Scan on tenk1 b
@@ -3318,7 +3291,7 @@ select count(*) from
33183291 Join Filter: (a.unique2 = b.unique1)
33193292 -> Remote Subquery Scan on all
33203293 Distribute results by H: thousand
3321- -> Seq Scan on tenk1 c
3294+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 c
33223295 -> Hash
33233296 -> Remote Subquery Scan on all
33243297 Distribute results by H: thousand
@@ -3363,7 +3336,7 @@ select b.unique1 from
33633336 Join Filter: (b.unique1 = 42)
33643337 -> Remote Subquery Scan on all
33653338 Distribute results by H: 42
3366- -> Seq Scan on tenk1 c
3339+ -> Index Only Scan using tenk1_thous_tenthous on tenk1 c
33673340 -> Hash
33683341 -> Remote Subquery Scan on all
33693342 Distribute results by H: unique1
@@ -3468,17 +3441,19 @@ select f1, unique2, case when unique2 is null then f1 else 0 end
34683441 QUERY PLAN
34693442--------------------------------------------------------------------------
34703443 Remote Subquery Scan on all
3471- -> Hash Right Join
3472- Hash Cond: (b.unique2 = a.f1)
3444+ -> Merge Right Join
3445+ Merge Cond: (b.unique2 = a.f1)
34733446 Filter: (CASE WHEN (b.unique2 IS NULL) THEN a.f1 ELSE 0 END = 0)
34743447 -> Remote Subquery Scan on all
34753448 Distribute results by H: unique2
3476- -> Seq Scan on tenk1 b
3477- -> Hash
3449+ -> Index Only Scan using tenk1_unique2 on tenk1 b
3450+ -> Materialize
34783451 -> Remote Subquery Scan on all
34793452 Distribute results by H: f1
3480- -> Seq Scan on int4_tbl a
3481- (11 rows)
3453+ -> Sort
3454+ Sort Key: a.f1
3455+ -> Seq Scan on int4_tbl a
3456+ (13 rows)
34823457
34833458select f1, unique2, case when unique2 is null then f1 else 0 end
34843459 from int4_tbl a left join tenk1 b on f1 = unique2
@@ -3537,33 +3512,37 @@ left join
35373512 using (join_key)
35383513 ) foo3
35393514using (join_key);
3540- QUERY PLAN
3541- -----------------------------------------------------------------------
3515+ QUERY PLAN
3516+ --------------------------------------------------------------------------------
35423517 Hash Right Join
35433518 Output: "*VALUES*".column1, i1.f1, (666)
35443519 Hash Cond: (i1.f1 = "*VALUES*".column1)
35453520 -> Remote Subquery Scan on all (datanode_1,datanode_2)
35463521 Output: i1.f1, 666
3547- -> Hash Right Join
3522+ -> Merge Right Join
35483523 Output: i1.f1, 666
3549- Hash Cond: (i2.unique2 = i1.f1)
3524+ Merge Cond: (i2.unique2 = i1.f1)
35503525 -> Remote Subquery Scan on all (datanode_1,datanode_2)
35513526 Output: i2.unique2
35523527 Distribute results by H: unique2
3553- -> Seq Scan on public.tenk1 i2
3528+ Sort Key: i2.unique2
3529+ -> Index Only Scan using tenk1_unique2 on public.tenk1 i2
35543530 Output: i2.unique2
3555- -> Hash
3531+ -> Materialize
35563532 Output: i1.f1
35573533 -> Remote Subquery Scan on all (datanode_1)
35583534 Output: i1.f1
35593535 Distribute results by H: f1
3560- -> Seq Scan on public.int4_tbl i1
3536+ -> Sort
35613537 Output: i1.f1
3538+ Sort Key: i1.f1
3539+ -> Seq Scan on public.int4_tbl i1
3540+ Output: i1.f1
35623541 -> Hash
35633542 Output: "*VALUES*".column1
35643543 -> Values Scan on "*VALUES*"
35653544 Output: "*VALUES*".column1
3566- (24 rows)
3545+ (28 rows)
35673546
35683547select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from
35693548 (values (0),(1)) foo1(join_key)
@@ -4720,19 +4699,18 @@ select * from generate_series(100,200) g,
47204699explain (num_nodes off, nodes off, costs off)
47214700 select count(*) from tenk1 a,
47224701 tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
4723- QUERY PLAN
4724- ------------------------------------------------------------
4702+ QUERY PLAN
4703+ ------------------------------------------------------------------------------
47254704 Finalize Aggregate
47264705 -> Remote Subquery Scan on all
47274706 -> Partial Aggregate
4728- -> Hash Join
4729- Hash Cond: (b.unique2 = a.unique1)
4730- -> Remote Subquery Scan on all
4731- Distribute results by H: unique2
4732- -> Seq Scan on tenk1 b
4733- -> Hash
4734- -> Seq Scan on tenk1 a
4735- (10 rows)
4707+ -> Merge Join
4708+ Merge Cond: (b.unique2 = a.unique1)
4709+ -> Remote Subquery Scan on all
4710+ Distribute results by H: unique2
4711+ -> Index Only Scan using tenk1_unique2 on tenk1 b
4712+ -> Index Only Scan using tenk1_unique1 on tenk1 a
4713+ (9 rows)
47364714
47374715select count(*) from tenk1 a,
47384716 tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
@@ -4745,18 +4723,18 @@ select count(*) from tenk1 a,
47454723explain (num_nodes off, nodes off, costs off)
47464724 select count(*) from tenk1 a,
47474725 tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
4748- QUERY PLAN
4749- -----------------------------------------------------
4726+ QUERY PLAN
4727+ ------------------------------------------------------------------------
47504728 Aggregate
47514729 -> Hash Join
47524730 Hash Cond: ("*VALUES*".column1 = b.unique2)
47534731 -> Nested Loop
47544732 -> Remote Subquery Scan on all
4755- -> Seq Scan on tenk1 a
4733+ -> Index Only Scan using tenk1_unique1 on tenk1 a
47564734 -> Values Scan on "*VALUES*"
47574735 -> Hash
47584736 -> Remote Subquery Scan on all
4759- -> Seq Scan on tenk1 b
4737+ -> Index Only Scan using tenk1_unique2 on tenk1 b
47604738(10 rows)
47614739
47624740select count(*) from tenk1 a,
@@ -6085,8 +6063,8 @@ from onek t1, tenk1 t2
60856063where exists (select 1 from tenk1 t3
60866064 where t3.thousand = t1.unique1 and t3.tenthous = t2.hundred)
60876065 and t1.unique1 < 1;
6088- QUERY PLAN
6089- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
6066+ QUERY PLAN
6067+ ---------------------------------------------------------------------------------------------------------
60906068 Remote Subquery Scan on all (datanode_1,datanode_2)
60916069 Output: t1.unique1, t2.hundred
60926070 -> Nested Loop
@@ -6101,13 +6079,13 @@ where exists (select 1 from tenk1 t3
61016079 Output: t3.thousand, t3.tenthous
61026080 Group Key: t3.thousand, t3.tenthous
61036081 -> Remote Subquery Scan on all (datanode_1,datanode_2)
6104- Output: t3.unique1, t3.unique2, t3.two, t3.four, t3.ten, t3.twenty, t3.hundred, t3. thousand, t3.twothousand, t3.fivethous, t3. tenthous, t3.odd, t3.even, t3.stringu1, t3.stringu2, t3.string4
6082+ Output: t3.thousand, t3.tenthous
61056083 Distribute results by H: thousand
61066084 -> HashAggregate
6107- Output: t3.unique1, t3.unique2, t3.two, t3.four, t3.ten, t3.twenty, t3.hundred, t3. thousand, t3.twothousand, t3.fivethous, t3. tenthous, t3.odd, t3.even, t3.stringu1, t3.stringu2, t3.string4
6085+ Output: t3.thousand, t3.tenthous
61086086 Group Key: t3.thousand, t3.tenthous
6109- -> Seq Scan on public.tenk1 t3
6110- Output: t3.unique1, t3.unique2, t3.two, t3.four, t3.ten, t3.twenty, t3.hundred, t3. thousand, t3.twothousand, t3.fivethous, t3. tenthous, t3.odd, t3.even, t3.stringu1, t3.stringu2, t3.string4
6087+ -> Index Only Scan using tenk1_thous_tenthous on public.tenk1 t3
6088+ Output: t3.thousand, t3.tenthous
61116089 -> Hash
61126090 Output: t1.unique1
61136091 -> Remote Subquery Scan on all (datanode_1,datanode_2)
0 commit comments