-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathexperimental_distsql_planning_5node
164 lines (144 loc) · 4.79 KB
/
experimental_distsql_planning_5node
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# LogicTest: 5node
# This test file makes sure that experimental DistSQL planning actually plans
# processors and other components correctly. In order to make the output
# deterministic we place the data manually.
statement ok
CREATE TABLE kv (k INT PRIMARY KEY, v INT, FAMILY (k, v));
INSERT INTO kv SELECT i, i FROM generate_series(1,5) AS g(i);
CREATE TABLE kw (k INT PRIMARY KEY, w INT, FAMILY (k, w));
INSERT INTO kw SELECT i, i FROM generate_series(1,5) AS g(i)
# Split into 5 parts, each row from each table goes to one node.
statement ok
ALTER TABLE kv SPLIT AT SELECT i FROM generate_series(1,5) AS g(i);
ALTER TABLE kw SPLIT AT SELECT i FROM generate_series(1,5) AS g(i);
ALTER TABLE kv EXPERIMENTAL_RELOCATE SELECT ARRAY[i], i FROM generate_series(1, 5) as g(i);
ALTER TABLE kw EXPERIMENTAL_RELOCATE SELECT ARRAY[i], i FROM generate_series(1, 5) as g(i)
# Verify data placement.
query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder from [SHOW RANGES FROM TABLE kv]
----
start_key end_key replicas lease_holder
NULL /1 {1} 1
/1 /2 {1} 1
/2 /3 {2} 2
/3 /4 {3} 3
/4 /5 {4} 4
/5 NULL {5} 5
# Verify data placement.
query TTTI colnames,rowsort
SELECT start_key, end_key, replicas, lease_holder from [SHOW RANGES FROM TABLE kw]
----
start_key end_key replicas lease_holder
NULL /1 {5} 5
/1 /2 {1} 1
/2 /3 {2} 2
/3 /4 {3} 3
/4 /5 {4} 4
/5 NULL {5} 5
statement ok
SET experimental_distsql_planning = always
query TTT
EXPLAIN SELECT * FROM kv
----
· distribution full
· vectorized true
query BT
EXPLAIN (DISTSQL) SELECT * FROM kv
----
true https://cockroachdb.github.io/distsqlplan/decode.html#eJyk0s9O4zAQBvD7PkX0nXZXjvJ_DzktgiJFKm1pekBCOYR4VEWkcbAdBKry7qjOobQqYOjR9nz-zUizhXpqkGJyt5heZDPn91WWr_Lb6R8nn0wnlyvnr3O9nN84j89gaAWnWbkhhfQeARhCMERgiMGQoGDopKhIKSF3JVsTyPgLUp-hbrte764LhkpIQrqFrnVDSLEqHxpaUslJej4YOOmybgzTyXpTytf_poG8K1uVOq4XohgYRK_3fypdrglpMLAP3D3Xt0JyksQPqGI40dlMuKLzkqPC03R4QAf2Iwdfj-yFrhdZDh3ay6GFHLlebClH9nJkIceul1jKsb0cW8iJ-4MFO-EuSXWiVWS1P_5uAYmvadxWJXpZ0UKKyjDjcW5y5oKT0uNrMB6y1jyZBt-Hg0_D_w7C_nE4PEeOzgnH54STb4WL4ddbAAAA__9oS6Od
# Note that we want to test DistSQL physical planning and the obvious choice
# would be to use EXPLAIN (DISTSQL). However, this explain variant doesn't have
# a textual mode which is easier to verify, so we use EXPLAIN (VEC) instead.
# TODO(yuzefovich): consider adding textual mode to EXPLAIN (DISTSQL) and
# using it here.
# TODO(yuzefovich): figure out how we would display plans that have distributed
# stages followed by local ones followed by distributed stages.
# An example of partially distributed plan (due to DOid type that is not
# supported by DistSQL).
query T
EXPLAIN (VEC) SELECT * FROM kv WHERE k::REGCLASS IS NOT NULL
----
│
├ Node 1
│ └ *colexec.isNullSelOp
│ └ *colexec.castOp
│ └ *colexec.ParallelUnorderedSynchronizer
│ ├ *colexec.colBatchScan
│ ├ *colrpc.Inbox
│ ├ *colrpc.Inbox
│ ├ *colrpc.Inbox
│ └ *colrpc.Inbox
├ Node 2
│ └ *colrpc.Outbox
│ └ *colexec.colBatchScan
├ Node 3
│ └ *colrpc.Outbox
│ └ *colexec.colBatchScan
├ Node 4
│ └ *colrpc.Outbox
│ └ *colexec.colBatchScan
└ Node 5
└ *colrpc.Outbox
└ *colexec.colBatchScan
# Check that the plan is local when experimental DistSQL planning is disabled.
statement ok
SET experimental_distsql_planning = off
query T
EXPLAIN (VEC) SELECT * FROM kv WHERE k::REGCLASS IS NOT NULL
----
│
└ Node 1
└ *colexec.isNullSelOp
└ *colexec.castOp
└ *colexec.colBatchScan
statement ok
SET experimental_distsql_planning = always
# Check that plan is partially distributed (due to DOid type in a render
# expression which is not supported by DistSQL).
query T
EXPLAIN (VEC) SELECT k::REGCLASS FROM kv
----
│
├ Node 1
│ └ *colexec.castOp
│ └ *colexec.ParallelUnorderedSynchronizer
│ ├ *colexec.colBatchScan
│ ├ *colrpc.Inbox
│ ├ *colrpc.Inbox
│ ├ *colrpc.Inbox
│ └ *colrpc.Inbox
├ Node 2
│ └ *colrpc.Outbox
│ └ *colexec.colBatchScan
├ Node 3
│ └ *colrpc.Outbox
│ └ *colexec.colBatchScan
├ Node 4
│ └ *colrpc.Outbox
│ └ *colexec.colBatchScan
└ Node 5
└ *colrpc.Outbox
└ *colexec.colBatchScan
query TTT
EXPLAIN SELECT k::REGCLASS FROM kv
----
· distribution partial
· vectorized true
# Check that hash join is supported by the new factory.
query II rowsort
SELECT kv.k, v FROM kv, kw WHERE v = w
----
1 1
2 2
3 3
4 4
5 5
# Check that merge join is supported by the new factory.
query I
SELECT kv.k FROM kv, kw WHERE kv.k = kw.k ORDER BY 1
----
1
2
3
4
5