Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
clmforever
oceanbase
提交
e0c0e303
O
oceanbase
项目概览
clmforever
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e0c0e303
编写于
3月 02, 2023
作者:
O
obdev
提交者:
ob-robot
3月 02, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix union all strict pw check logic
上级
e460d049
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
94 addition
and
72 deletion
+94
-72
src/sql/optimizer/ob_select_log_plan.cpp
src/sql/optimizer/ob_select_log_plan.cpp
+31
-4
src/sql/optimizer/ob_sharding_info.cpp
src/sql/optimizer/ob_sharding_info.cpp
+0
-25
src/sql/optimizer/ob_sharding_info.h
src/sql/optimizer/ob_sharding_info.h
+0
-4
tools/deploy/mysql_test/test_suite/optimizer/r/mysql/equal_set_mysql.result
..._test/test_suite/optimizer/r/mysql/equal_set_mysql.result
+63
-39
未找到文件。
src/sql/optimizer/ob_select_log_plan.cpp
浏览文件 @
e0c0e303
...
...
@@ -2142,21 +2142,48 @@ int ObSelectLogPlan::check_if_union_all_match_partition_wise(const ObIArray<ObLo
bool
&
is_partition_wise
)
{
int
ret
=
OB_SUCCESS
;
EqualSets
equal_sets
;
EqualSets
first_equal_sets
;
ObShardingInfo
*
first_sharding
=
NULL
;
ObShardingInfo
*
child_sharding
=
NULL
;
const
ObSelectStmt
*
child_stmt
=
NULL
;
ObSEArray
<
ObRawExpr
*
,
4
>
first_select_exprs
;
ObSEArray
<
ObRawExpr
*
,
4
>
child_select_exprs
;
is_partition_wise
=
true
;
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
is_partition_wise
&&
i
<
child_ops
.
count
();
i
++
)
{
equal_sets
.
reset
();
child_select_exprs
.
reset
();
if
(
OB_ISNULL
(
child_ops
.
at
(
i
))
||
OB_ISNULL
(
child_sharding
=
child_ops
.
at
(
i
)
->
get_sharding
()))
{
OB_ISNULL
(
child_sharding
=
child_ops
.
at
(
i
)
->
get_sharding
())
||
OB_ISNULL
(
child_ops
.
at
(
i
)
->
get_plan
())
||
OB_ISNULL
(
child_ops
.
at
(
i
)
->
get_plan
()
->
get_stmt
())
||
!
child_ops
.
at
(
i
)
->
get_plan
()
->
get_stmt
()
->
is_select_stmt
()
||
OB_ISNULL
(
child_stmt
=
static_cast
<
const
ObSelectStmt
*>
(
child_ops
.
at
(
i
)
->
get_plan
()
->
get_stmt
())))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"get unexpected null"
,
K
(
child_ops
.
at
(
i
)),
K
(
child_sharding
),
K
(
ret
));
}
else
if
(
child_ops
.
at
(
i
)
->
is_exchange_allocated
())
{
is_partition_wise
=
false
;
}
else
if
(
i
==
0
)
{
first_sharding
=
child_sharding
;
}
else
if
(
OB_FAIL
(
ObShardingInfo
::
is_physically_equal_partitioned
(
*
first_sharding
,
*
child_sharding
,
is_partition_wise
)))
{
first_equal_sets
=
child_ops
.
at
(
i
)
->
get_output_equal_sets
();
if
(
OB_FAIL
(
child_stmt
->
get_select_exprs
(
first_select_exprs
)))
{
LOG_WARN
(
"failed to get select exprs"
,
K
(
ret
));
}
}
else
if
(
OB_FAIL
(
child_stmt
->
get_select_exprs
(
child_select_exprs
)))
{
LOG_WARN
(
"failed to get select exprs"
,
K
(
ret
));
}
else
if
(
first_select_exprs
.
count
()
!=
child_select_exprs
.
count
())
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"select exprs count doesn't match"
,
K
(
first_select_exprs
),
K
(
child_select_exprs
));
}
else
if
(
OB_FAIL
(
append
(
equal_sets
,
first_equal_sets
)))
{
LOG_WARN
(
"failed to append equal sets"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
append
(
equal_sets
,
child_ops
.
at
(
i
)
->
get_output_equal_sets
())))
{
LOG_WARN
(
"failed to append equal sets"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
ObShardingInfo
::
check_if_match_partition_wise
(
equal_sets
,
first_select_exprs
,
child_select_exprs
,
first_sharding
,
child_sharding
,
is_partition_wise
)))
{
LOG_WARN
(
"failed to check if union all match strict partition-wise"
,
K
(
ret
));
}
else
{
LOG_TRACE
(
"succ to check union all matching pw"
,
K
(
is_partition_wise
));
...
...
src/sql/optimizer/ob_sharding_info.cpp
浏览文件 @
e0c0e303
...
...
@@ -725,31 +725,6 @@ int ObShardingInfo::check_if_match_repart_or_rehash(const EqualSets &equal_sets,
return
ret
;
}
int
ObShardingInfo
::
is_physically_equal_partitioned
(
const
ObShardingInfo
&
left_sharding
,
const
ObShardingInfo
&
right_sharding
,
bool
&
is_equal_partition
)
{
int
ret
=
OB_SUCCESS
;
is_equal_partition
=
false
;
PwjTable
l_table
;
PwjTable
r_table
;
ObStrictPwjComparer
pwj_comparer
;
if
(
OB_FAIL
(
l_table
.
init
(
left_sharding
)))
{
LOG_WARN
(
"failed to init pwj table with sharding info"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
r_table
.
init
(
right_sharding
)))
{
LOG_WARN
(
"failed to init pwj table with sharding info"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
pwj_comparer
.
add_table
(
l_table
,
is_equal_partition
)))
{
LOG_WARN
(
"failed to add table"
,
K
(
ret
));
}
else
if
(
!
is_equal_partition
)
{
// do nothing
}
else
if
(
OB_FAIL
(
pwj_comparer
.
add_table
(
r_table
,
is_equal_partition
)))
{
LOG_WARN
(
"failed to add table"
,
K
(
ret
));
}
else
{
// do nothing
}
return
ret
;
}
int
ObShardingInfo
::
is_physically_equal_serverlist
(
ObIArray
<
ObAddr
>
&
left_server_list
,
ObIArray
<
ObAddr
>
&
right_server_list
,
bool
&
is_equal_serverlist
)
...
...
src/sql/optimizer/ob_sharding_info.h
浏览文件 @
e0c0e303
...
...
@@ -182,10 +182,6 @@ public:
const
common
::
ObIArray
<
ObRawExpr
*>
&
target_part_keys
,
bool
&
is_match_join_keys
);
static
int
is_physically_equal_partitioned
(
const
ObShardingInfo
&
left_sharding
,
const
ObShardingInfo
&
right_sharding
,
bool
&
is_equal_partition
);
static
int
is_physically_both_shuffled_serverlist
(
ObIArray
<
ObAddr
>
&
left_server_list
,
ObIArray
<
ObAddr
>
&
right_server_list
,
bool
&
is_both_shuffled_serverlist
);
...
...
tools/deploy/mysql_test/test_suite/optimizer/r/mysql/equal_set_mysql.result
浏览文件 @
e0c0e303
...
...
@@ -6568,11 +6568,13 @@ Query Plan
|3 | EXCHANGE IN DISTR | |1 |26 |
|4 | EXCHANGE OUT DISTR (HASH)|:EX10000|1 |26 |
|5 | HASH DISTINCT | |1 |26 |
|6 |
PX PARTITION ITERATOR
| |3 |26 |
|7 |
UNION ALL | |3 |26
|
|6 |
UNION ALL
| |3 |26 |
|7 |
PX PARTITION ITERATOR | |1 |9
|
|8 | TABLE SCAN |t1 |1 |9 |
|9 | TABLE SCAN |t2 |1 |9 |
|10| TABLE SCAN |t3 |1 |9 |
|9 | PX PARTITION ITERATOR | |1 |9 |
|10| TABLE SCAN |t2 |1 |9 |
|11| PX PARTITION ITERATOR | |1 |9 |
|12| TABLE SCAN |t3 |1 |9 |
=================================================================
Outputs & filters:
-------------------------------------
...
...
@@ -6587,17 +6589,21 @@ Outputs & filters:
5 - output([UNION([1])]), filter(nil), rowset=256
distinct([UNION([1])])
6 - output([UNION([1])]), filter(nil), rowset=256
partition wise, force partition granule
7 - output([UNION([1])]), filter(nil), rowset=256
7 - output([t1.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
8 - output([t1.a]), filter(nil), rowset=256
access([t1.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t1.__pk_increment]), range(MIN ; MAX)always true
9 - output([t2.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
10 - output([t2.a]), filter(nil), rowset=256
access([t2.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t2.__pk_increment]), range(MIN ; MAX)always true
10 - output([t3.b]), filter(nil), rowset=256
11 - output([t3.b]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
12 - output([t3.b]), filter(nil), rowset=256
access([t3.b]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t3.__pk_increment]), range(MIN ; MAX)always true
...
...
@@ -6968,13 +6974,15 @@ Query Plan
|7 | EXCHANGE IN DISTR | |1 |26 |
|8 | EXCHANGE OUT DISTR (HASH)|:EX10000|1 |26 |
|9 | HASH DISTINCT | |1 |26 |
|10|
PX PARTITION ITERATOR
| |3 |26 |
|11|
UNION ALL | |3 |26
|
|10|
UNION ALL
| |3 |26 |
|11|
PX PARTITION ITERATOR | |1 |9
|
|12| TABLE SCAN |t1 |1 |9 |
|13| TABLE SCAN |t2 |1 |9 |
|14| TABLE SCAN |t3 |1 |9 |
|15| PX PARTITION ITERATOR | |1 |9 |
|16| TABLE SCAN |t5 |1 |9 |
|13| PX PARTITION ITERATOR | |1 |9 |
|14| TABLE SCAN |t2 |1 |9 |
|15| PX PARTITION ITERATOR | |1 |9 |
|16| TABLE SCAN |t3 |1 |9 |
|17| PX PARTITION ITERATOR | |1 |9 |
|18| TABLE SCAN |t5 |1 |9 |
=====================================================================
Outputs & filters:
-------------------------------------
...
...
@@ -6996,23 +7004,27 @@ Outputs & filters:
9 - output([UNION([1])]), filter(nil), rowset=256
distinct([UNION([1])])
10 - output([UNION([1])]), filter(nil), rowset=256
partition wise, force partition granule
11 - output([UNION([1])]), filter(nil), rowset=256
11 - output([t1.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
12 - output([t1.a]), filter(nil), rowset=256
access([t1.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t1.__pk_increment]), range(MIN ; MAX)always true
13 - output([t2.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
14 - output([t2.a]), filter(nil), rowset=256
access([t2.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t2.__pk_increment]), range(MIN ; MAX)always true
14 - output([t3.b]), filter(nil), rowset=256
15 - output([t3.b]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
16 - output([t3.b]), filter(nil), rowset=256
access([t3.b]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t3.__pk_increment]), range(MIN ; MAX)always true
1
5
- output([t5.a], [t5.b], [t5.c]), filter(nil), rowset=256
1
7
- output([t5.a], [t5.b], [t5.c]), filter(nil), rowset=256
affinitize, force partition granule
1
6
- output([t5.a], [t5.b], [t5.c]), filter(nil), rowset=256
1
8
- output([t5.a], [t5.b], [t5.c]), filter(nil), rowset=256
access([t5.a], [t5.b], [t5.c]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t5.__pk_increment]), range(MIN ; MAX)always true
...
...
@@ -7367,34 +7379,40 @@ Outputs & filters:
range_key([t2.__pk_increment]), range(MIN ; MAX)always true
explain select a from t1 union all select a from t2 union all select b from t3;
Query Plan
===========================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
-----------------------------------------------------------
|0 |PX COORDINATOR | |3 |27 |
|1 | EXCHANGE OUT DISTR |:EX10000|3 |27 |
|2 | PX PARTITION ITERATOR| |3 |26 |
|3 | UNION ALL | |3 |26 |
|4 | TABLE SCAN |t1 |1 |9 |
|5 | TABLE SCAN |t2 |1 |9 |
|6 | TABLE SCAN |t3 |1 |9 |
===========================================================
============================================================
|ID|OPERATOR |NAME |EST.ROWS|EST.TIME(us)|
------------------------------------------------------------
|0 |PX COORDINATOR | |3 |27 |
|1 | EXCHANGE OUT DISTR |:EX10000|3 |27 |
|2 | UNION ALL | |3 |26 |
|3 | PX PARTITION ITERATOR| |1 |9 |
|4 | TABLE SCAN |t1 |1 |9 |
|5 | PX PARTITION ITERATOR| |1 |9 |
|6 | TABLE SCAN |t2 |1 |9 |
|7 | PX PARTITION ITERATOR| |1 |9 |
|8 | TABLE SCAN |t3 |1 |9 |
============================================================
Outputs & filters:
-------------------------------------
0 - output([INTERNAL_FUNCTION(UNION([1]))]), filter(nil), rowset=256
1 - output([INTERNAL_FUNCTION(UNION([1]))]), filter(nil), rowset=256
dop=1
2 - output([UNION([1])]), filter(nil), rowset=256
partition wise, force partition granule
3 - output([UNION([1])]), filter(nil), rowset=256
3 - output([t1.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
4 - output([t1.a]), filter(nil), rowset=256
access([t1.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t1.__pk_increment]), range(MIN ; MAX)always true
5 - output([t2.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
6 - output([t2.a]), filter(nil), rowset=256
access([t2.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t2.__pk_increment]), range(MIN ; MAX)always true
6 - output([t3.b]), filter(nil), rowset=256
7 - output([t3.b]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
8 - output([t3.b]), filter(nil), rowset=256
access([t3.b]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t3.__pk_increment]), range(MIN ; MAX)always true
...
...
@@ -7742,11 +7760,13 @@ Query Plan
|5 | EXCHANGE IN DISTR | |3 |27 |
|6 | EXCHANGE OUT DISTR (PKEY)|:EX10000|3 |27 |
|7 | SUBPLAN SCAN |t4 |3 |26 |
|8 |
PX PARTITION ITERATOR
| |3 |26 |
|9 |
UNION ALL | |3 |26
|
|8 |
UNION ALL
| |3 |26 |
|9 |
PX PARTITION ITERATOR | |1 |9
|
|10| TABLE SCAN |t1 |1 |9 |
|11| TABLE SCAN |t2 |1 |9 |
|12| TABLE SCAN |t3 |1 |9 |
|11| PX PARTITION ITERATOR | |1 |9 |
|12| TABLE SCAN |t2 |1 |9 |
|13| PX PARTITION ITERATOR | |1 |9 |
|14| TABLE SCAN |t3 |1 |9 |
=================================================================
Outputs & filters:
-------------------------------------
...
...
@@ -7767,17 +7787,21 @@ Outputs & filters:
7 - output([t4.a]), filter(nil), rowset=256
access([t4.a])
8 - output([UNION([1])]), filter(nil), rowset=256
partition wise, force partition granule
9 - output([UNION([1])]), filter(nil), rowset=256
9 - output([t1.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
10 - output([t1.a]), filter(nil), rowset=256
access([t1.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t1.__pk_increment]), range(MIN ; MAX)always true
11 - output([t2.a]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
12 - output([t2.a]), filter(nil), rowset=256
access([t2.a]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t2.__pk_increment]), range(MIN ; MAX)always true
12 - output([t3.b]), filter(nil), rowset=256
13 - output([t3.b]), filter(nil), rowset=256
affinitize, partition wise, force partition granule
14 - output([t3.b]), filter(nil), rowset=256
access([t3.b]), partitions(p[0-4])
is_index_back=false, is_global_index=false,
range_key([t3.__pk_increment]), range(MIN ; MAX)always true
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录