|
2 | 2 | slug: parallel-execution-I |
3 | 3 | title: 'Mastering Parallel Execution in OceanBase Database: Part 1 - Introduction' |
4 | 4 | --- |
| 5 | +# Mastering Parallel Execution in OceanBase Database: Part 1 - Introduction |
5 | 6 |
|
6 | 7 | > Message from the Author: |
7 | 8 | > This is a long-expected systematic guide on parallel execution (PX). |
@@ -162,52 +163,11 @@ As shown in the following figure: |
162 | 163 |
|
163 | 164 |
|
164 | 165 | Here is a sample query: |
| 166 | + |
165 | 167 |
|
166 | | - create table game (round int primary key, team varchar(10), score int) |
167 | | - partition by hash(round) partitions 3; |
168 | | - |
169 | | - insert into game values (1, "CN", 4), (2, "CN", 5), (3, "JP", 3); |
170 | | - insert into game values (4, "CN", 4), (5, "US", 4), (6, "JP", 4); |
171 | | - |
172 | | - select /*+ parallel(3) */ team, sum(score) total from game group by team; |
173 | 168 |
|
174 | 169 | The execution plan for the query statement is as follows: |
175 | | - |
176 | | - OceanBase(admin@test)>explain select /*+ parallel(3) */ team, sum(score) total from game group by team; |
177 | | - +---------------------------------------------------------------------------------------------------------+ |
178 | | - | Query Plan | |
179 | | - +---------------------------------------------------------------------------------------------------------+ |
180 | | - | ================================================================= | |
181 | | - | |ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)| | |
182 | | - | ----------------------------------------------------------------- | |
183 | | - | |0 |PX COORDINATOR | |1 |4 | | |
184 | | - | |1 | EXCHANGE OUT DISTR |:EX10001|1 |4 | | |
185 | | - | |2 | HASH GROUP BY | |1 |4 | | |
186 | | - | |3 | EXCHANGE IN DISTR | |3 |3 | | |
187 | | - | |4 | EXCHANGE OUT DISTR (HASH)|:EX10000|3 |3 | | |
188 | | - | |5 | HASH GROUP BY | |3 |2 | | |
189 | | - | |6 | PX BLOCK ITERATOR | |1 |2 | | |
190 | | - | |7 | TABLE SCAN |game |1 |2 | | |
191 | | - | ================================================================= | |
192 | | - | Outputs & filters: | |
193 | | - | ------------------------------------- | |
194 | | - | 0 - output([INTERNAL_FUNCTION(game.team, T_FUN_SUM(T_FUN_SUM(game.score)))]), filter(nil), rowset=256 | |
195 | | - | 1 - output([INTERNAL_FUNCTION(game.team, T_FUN_SUM(T_FUN_SUM(game.score)))]), filter(nil), rowset=256 | |
196 | | - | dop=3 | |
197 | | - | 2 - output([game.team], [T_FUN_SUM(T_FUN_SUM(game.score))]), filter(nil), rowset=256 | |
198 | | - | group([game.team]), agg_func([T_FUN_SUM(T_FUN_SUM(game.score))]) | |
199 | | - | 3 - output([game.team], [T_FUN_SUM(game.score)]), filter(nil), rowset=256 | |
200 | | - | 4 - output([game.team], [T_FUN_SUM(game.score)]), filter(nil), rowset=256 | |
201 | | - | (#keys=1, [game.team]), dop=3 | |
202 | | - | 5 - output([game.team], [T_FUN_SUM(game.score)]), filter(nil), rowset=256 | |
203 | | - | group([game.team]), agg_func([T_FUN_SUM(game.score)]) | |
204 | | - | 6 - output([game.team], [game.score]), filter(nil), rowset=256 | |
205 | | - | 7 - output([game.team], [game.score]), filter(nil), rowset=256 | |
206 | | - | access([game.team], [game.score]), partitions(p[0-2]) | |
207 | | - | is_index_back=false, is_global_index=false, | |
208 | | - | range_key([game.round]), range(MIN ; MAX)always true | |
209 | | - +---------------------------------------------------------------------------------------------------------+ |
210 | | - 29 rows in set (0.003 sec) |
| 170 | + |
211 | 171 |
|
212 | 172 | The execution plan of the `SELECT` statement first performs a full-table scan on the `game` table to group the data by team, and then calculates the total score of each team. The following figure demonstrates the query execution process. |
213 | 173 |
|
|
0 commit comments