Skip to content

Commit 81a5f31

Browse files
committed
orca: add parallel scan test
1 parent d2ee2fc commit 81a5f31

3 files changed

Lines changed: 154 additions & 0 deletions

File tree

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
create schema orca_parallel;
2+
set search_path=orca_parallel, public;
3+
set statement_mem = '256MB';
4+
set optimizer=on;
5+
create table t1(a int, b int) with(parallel_workers=2) distributed by (a);
6+
create table t2(c int, d int ) with(parallel_workers=3) distributed by (c);
7+
insert into t1 select i, i+1 from generate_series(1, 1000)i;
8+
insert into t2 select i, i+2 from generate_series(1, 20000)i;
9+
analyze t1;
10+
analyze t2;
11+
set parallel_setup_cost=0;
12+
set max_parallel_workers_per_gather=4;
13+
set enable_parallel = on;
14+
explain (verbose, costs off) select * from t1 join t2 on t1.a = t2.c;
15+
QUERY PLAN
16+
-------------------------------------------------------------------------------
17+
Gather Motion 3:1 (slice1; segments: 3)
18+
Output: t1.a, t1.b, t2.c, t2.d
19+
-> Hash Join
20+
Output: t1.a, t1.b, t2.c, t2.d
21+
Hash Cond: (t2.c = t1.a)
22+
-> Redistribute Motion 9:3 (slice2; segments: 9)
23+
Output: t2.c, t2.d
24+
Hash Key: t2.c
25+
-> Parallel Seq Scan on orca_parallel.t2
26+
Output: t2.c, t2.d
27+
-> Hash
28+
Output: t1.a, t1.b
29+
-> Redistribute Motion 6:3 (slice3; segments: 6)
30+
Output: t1.a, t1.b
31+
Hash Key: t1.a
32+
-> Parallel Seq Scan on orca_parallel.t1
33+
Output: t1.a, t1.b
34+
Settings: enable_parallel = 'on', optimizer = 'on', parallel_setup_cost = '0'
35+
Optimizer: GPORCA
36+
(19 rows)
37+
38+
explain (verbose, costs off) select * from t1 join t2 on t1.a = t2.d;
39+
QUERY PLAN
40+
-------------------------------------------------------------------------------
41+
Gather Motion 3:1 (slice1; segments: 3)
42+
Output: t1.a, t1.b, t2.c, t2.d
43+
-> Hash Join
44+
Output: t1.a, t1.b, t2.c, t2.d
45+
Hash Cond: (t2.d = t1.a)
46+
-> Redistribute Motion 9:3 (slice2; segments: 9)
47+
Output: t2.c, t2.d
48+
Hash Key: t2.d
49+
-> Parallel Seq Scan on orca_parallel.t2
50+
Output: t2.c, t2.d
51+
-> Hash
52+
Output: t1.a, t1.b
53+
-> Redistribute Motion 6:3 (slice3; segments: 6)
54+
Output: t1.a, t1.b
55+
Hash Key: t1.a
56+
-> Parallel Seq Scan on orca_parallel.t1
57+
Output: t1.a, t1.b
58+
Settings: enable_parallel = 'on', optimizer = 'on', parallel_setup_cost = '0'
59+
Optimizer: GPORCA
60+
(19 rows)
61+
62+
explain (verbose, costs off) select * from t1 join t2 on t1.b = t2.c;
63+
QUERY PLAN
64+
-------------------------------------------------------------------------------
65+
Gather Motion 3:1 (slice1; segments: 3)
66+
Output: t1.a, t1.b, t2.c, t2.d
67+
-> Hash Join
68+
Output: t1.a, t1.b, t2.c, t2.d
69+
Hash Cond: (t2.c = t1.b)
70+
-> Redistribute Motion 9:3 (slice2; segments: 9)
71+
Output: t2.c, t2.d
72+
Hash Key: t2.c
73+
-> Parallel Seq Scan on orca_parallel.t2
74+
Output: t2.c, t2.d
75+
-> Hash
76+
Output: t1.a, t1.b
77+
-> Redistribute Motion 6:3 (slice3; segments: 6)
78+
Output: t1.a, t1.b
79+
Hash Key: t1.b
80+
-> Parallel Seq Scan on orca_parallel.t1
81+
Output: t1.a, t1.b
82+
Settings: enable_parallel = 'on', optimizer = 'on', parallel_setup_cost = '0'
83+
Optimizer: GPORCA
84+
(19 rows)
85+
86+
explain (verbose, costs off) select * from t1 join t2 on t1.b = t2.d;
87+
QUERY PLAN
88+
-------------------------------------------------------------------------------
89+
Gather Motion 3:1 (slice1; segments: 3)
90+
Output: t1.a, t1.b, t2.c, t2.d
91+
-> Hash Join
92+
Output: t1.a, t1.b, t2.c, t2.d
93+
Hash Cond: (t2.d = t1.b)
94+
-> Redistribute Motion 9:3 (slice2; segments: 9)
95+
Output: t2.c, t2.d
96+
Hash Key: t2.d
97+
-> Parallel Seq Scan on orca_parallel.t2
98+
Output: t2.c, t2.d
99+
-> Hash
100+
Output: t1.a, t1.b
101+
-> Redistribute Motion 6:3 (slice3; segments: 6)
102+
Output: t1.a, t1.b
103+
Hash Key: t1.b
104+
-> Parallel Seq Scan on orca_parallel.t1
105+
Output: t1.a, t1.b
106+
Settings: enable_parallel = 'on', optimizer = 'on', parallel_setup_cost = '0'
107+
Optimizer: GPORCA
108+
(19 rows)
109+
110+
reset enable_parallel;
111+
reset max_parallel_workers_per_gather;
112+
reset parallel_setup_cost;
113+
reset statement_mem;
114+
reset optimizer;
115+
-- start_ignore
116+
drop schema orca_parallel cascade;
117+
NOTICE: drop cascades to 2 other objects
118+
DETAIL: drop cascades to table t1
119+
drop cascades to table t2
120+
-- end_ignore

src/test/regress/parallel_schedule

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,5 +194,8 @@ test: constraints_check
194194
# run stats by itself because its delay may be insufficient under heavy load
195195
test: stats
196196

197+
# orca parallel
198+
test: orca_parallel
199+
197200
# test of tag
198201
test: tag
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
create schema orca_parallel;
2+
set search_path=orca_parallel, public;
3+
set statement_mem = '256MB';
4+
set optimizer=on;
5+
6+
create table t1(a int, b int) with(parallel_workers=2) distributed by (a);
7+
create table t2(c int, d int ) with(parallel_workers=3) distributed by (c);
8+
insert into t1 select i, i+1 from generate_series(1, 1000)i;
9+
insert into t2 select i, i+2 from generate_series(1, 20000)i;
10+
analyze t1;
11+
analyze t2;
12+
13+
set parallel_setup_cost=0;
14+
set max_parallel_workers_per_gather=4;
15+
set enable_parallel = on;
16+
17+
explain (verbose, costs off) select * from t1 join t2 on t1.a = t2.c;
18+
explain (verbose, costs off) select * from t1 join t2 on t1.a = t2.d;
19+
explain (verbose, costs off) select * from t1 join t2 on t1.b = t2.c;
20+
explain (verbose, costs off) select * from t1 join t2 on t1.b = t2.d;
21+
22+
23+
reset enable_parallel;
24+
reset max_parallel_workers_per_gather;
25+
reset parallel_setup_cost;
26+
reset statement_mem;
27+
reset optimizer;
28+
29+
-- start_ignore
30+
drop schema orca_parallel cascade;
31+
-- end_ignore

0 commit comments

Comments
 (0)