Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
kp22424
oceanbase
提交
62a73687
O
oceanbase
项目概览
kp22424
/
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,体验更适合开发者的 AI 搜索 >>
提交
62a73687
编写于
12月 21, 2021
作者:
Y
yb0
提交者:
LINGuanRen
12月 21, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine plan generate strategy for remote sql
上级
fe44cd94
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
39 deletion
+21
-39
src/sql/optimizer/ob_join_order.cpp
src/sql/optimizer/ob_join_order.cpp
+2
-37
src/sql/optimizer/ob_optimizer.cpp
src/sql/optimizer/ob_optimizer.cpp
+19
-2
未找到文件。
src/sql/optimizer/ob_join_order.cpp
浏览文件 @
62a73687
...
@@ -2288,21 +2288,15 @@ int ObJoinOrder::add_cte_table(const uint64_t table_id, const uint64_t ref_id)
...
@@ -2288,21 +2288,15 @@ int ObJoinOrder::add_cte_table(const uint64_t table_id, const uint64_t ref_id)
int
ObJoinOrder
::
compute_cost_and_prune_access_path
(
PathHelper
&
helper
,
ObIArray
<
AccessPath
*>&
access_paths
)
int
ObJoinOrder
::
compute_cost_and_prune_access_path
(
PathHelper
&
helper
,
ObIArray
<
AccessPath
*>&
access_paths
)
{
{
int
ret
=
OB_SUCCESS
;
int
ret
=
OB_SUCCESS
;
ObSqlCtx* sql_ctx = NULL;
if
(
OB_ISNULL
(
get_plan
()))
{
ObTaskExecutorCtx* task_exec_ctx = NULL;
if (OB_ISNULL(get_plan()) || OB_ISNULL(get_plan()->get_optimizer_context().get_exec_ctx()) ||
OB_ISNULL(task_exec_ctx = get_plan()->get_optimizer_context().get_task_exec_ctx()) ||
OB_ISNULL(sql_ctx = get_plan()->get_optimizer_context().get_exec_ctx()->get_sql_ctx())) {
ret
=
OB_ERR_UNEXPECTED
;
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN("get unexpected null", K(get_plan()), K(
sql_ctx), K(
ret));
LOG_WARN
(
"get unexpected null"
,
K
(
get_plan
()),
K
(
ret
));
}
else
{
}
else
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
access_paths
.
count
();
++
i
)
{
for
(
int64_t
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
access_paths
.
count
();
++
i
)
{
AccessPath
*
ap
=
access_paths
.
at
(
i
);
AccessPath
*
ap
=
access_paths
.
at
(
i
);
if
(
OB_ISNULL
(
ap
)
||
OB_ISNULL
(
ap
->
get_sharding_info
()))
{
if
(
OB_ISNULL
(
ap
)
||
OB_ISNULL
(
ap
->
get_sharding_info
()))
{
ret
=
OB_ERR_UNEXPECTED
;
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"get unexpected null"
,
K
(
ap
),
K
(
ret
));
LOG_WARN
(
"get unexpected null"
,
K
(
ap
),
K
(
ret
));
} else if (sql_ctx->is_remote_sql_ && ap->get_sharding_info()->is_remote_or_distribute()) {
/*do nothing*/
}
else
if
(
OB_FAIL
(
ap
->
estimate_cost
()))
{
}
else
if
(
OB_FAIL
(
ap
->
estimate_cost
()))
{
LOG_WARN
(
"failed to get index access info"
,
K
(
*
ap
),
K
(
ret
));
LOG_WARN
(
"failed to get index access info"
,
K
(
*
ap
),
K
(
ret
));
}
else
if
(
!
ap
->
is_inner_path
())
{
}
else
if
(
!
ap
->
is_inner_path
())
{
...
@@ -2322,35 +2316,6 @@ int ObJoinOrder::compute_cost_and_prune_access_path(PathHelper& helper, ObIArray
...
@@ -2322,35 +2316,6 @@ int ObJoinOrder::compute_cost_and_prune_access_path(PathHelper& helper, ObIArray
}
}
}
}
}
// add path end
}
// add path end
if (OB_SUCC(ret) && sql_ctx->is_remote_sql_ && interesting_paths_.empty() && !helper.is_inner_path_) {
// for the purpose to refresh location cache
ObSEArray<ObTablePartitionInfo*, 8> table_partitions;
for (int64_t i = 0; OB_SUCC(ret) && i < access_paths.count(); i++) {
AccessPath* path = NULL;
if (OB_ISNULL(path = access_paths.at(i)) || OB_ISNULL(path->table_partition_info_)) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("get unexpected null", K(ret), K(path));
} else if (1 != path->table_partition_info_->get_phy_tbl_location_info().get_phy_part_loc_info_list().count()) {
// do nothing
} else if (is_contain(table_partitions, path->table_partition_info_)) {
/*do nothing*/
} else if (OB_FAIL(path->table_partition_info_->set_log_op_infos(path->index_id_, path->order_direction_))) {
LOG_WARN("failed to set log op infos", K(ret));
} else if (OB_FAIL(table_partitions.push_back(path->table_partition_info_))) {
LOG_WARN("failed to push back table partition", K(ret));
} else { /*do nothing*/
}
}
if (OB_FAIL(ret)) {
/*do nothing*/
} else if (OB_FAIL(task_exec_ctx->append_table_locations_no_dup(table_partitions))) {
LOG_WARN("failed to append table locations no dup", K(ret));
} else {
ret = (get_plan()->get_optimizer_context().is_cost_evaluation() ? OB_SQL_OPT_GEN_PLAN_FALIED
: OB_LOCATION_NOT_EXIST);
LOG_WARN("no available local path for remote sql", K(ret));
}
}
}
}
return
ret
;
return
ret
;
}
}
...
...
src/sql/optimizer/ob_optimizer.cpp
浏览文件 @
62a73687
...
@@ -29,9 +29,10 @@ int ObOptimizer::optimize(ObDMLStmt& stmt, ObLogPlan*& logical_plan)
...
@@ -29,9 +29,10 @@ int ObOptimizer::optimize(ObDMLStmt& stmt, ObLogPlan*& logical_plan)
const
ObSQLSessionInfo
*
session
=
ctx_
.
get_session_info
();
const
ObSQLSessionInfo
*
session
=
ctx_
.
get_session_info
();
int64_t
last_mem_usage
=
ctx_
.
get_allocator
().
total
();
int64_t
last_mem_usage
=
ctx_
.
get_allocator
().
total
();
int64_t
optimizer_mem_usage
=
0
;
int64_t
optimizer_mem_usage
=
0
;
if
(
OB_ISNULL
(
query_ctx
)
||
OB_ISNULL
(
session
))
{
ObTaskExecutorCtx
*
task_exec_ctx
=
ctx_
.
get_task_exec_ctx
();
if
(
OB_ISNULL
(
query_ctx
)
||
OB_ISNULL
(
session
)
||
OB_ISNULL
(
task_exec_ctx
))
{
ret
=
OB_INVALID_ARGUMENT
;
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"invalid arguments"
,
K
(
ret
),
K
(
query_ctx
),
K
(
session
));
LOG_WARN
(
"invalid arguments"
,
K
(
ret
),
K
(
query_ctx
),
K
(
session
)
,
K
(
task_exec_ctx
)
);
}
else
if
(
OB_FAIL
(
init_env_info
(
stmt
)))
{
}
else
if
(
OB_FAIL
(
init_env_info
(
stmt
)))
{
LOG_WARN
(
"failed to init px info"
,
K
(
ret
));
LOG_WARN
(
"failed to init px info"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
generate_plan_for_temp_table
(
stmt
)))
{
}
else
if
(
OB_FAIL
(
generate_plan_for_temp_table
(
stmt
)))
{
...
@@ -62,6 +63,22 @@ int ObOptimizer::optimize(ObDMLStmt& stmt, ObLogPlan*& logical_plan)
...
@@ -62,6 +63,22 @@ int ObOptimizer::optimize(ObDMLStmt& stmt, ObLogPlan*& logical_plan)
LOG_USER_ERROR
(
OB_OP_NOT_ALLOW
,
"Access tables from multiple tenants"
);
LOG_USER_ERROR
(
OB_OP_NOT_ALLOW
,
"Access tables from multiple tenants"
);
}
}
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
ctx_
.
get_exec_ctx
()
->
get_sql_ctx
()
->
is_remote_sql_
&&
plan
->
get_phy_plan_type
()
!=
OB_PHY_PLAN_LOCAL
)
{
// set table location to refresh location cache
ObSEArray
<
ObTablePartitionInfo
*
,
8
>
table_partitions
;
if
(
OB_FAIL
(
plan
->
get_global_table_partition_info
(
table_partitions
)))
{
LOG_WARN
(
"failed to get global table partition info"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
task_exec_ctx
->
set_table_locations
(
table_partitions
)))
{
LOG_WARN
(
"failed to set table locations"
,
K
(
ret
));
}
if
(
OB_SUCC
(
ret
))
{
ret
=
OB_LOCATION_NOT_EXIST
;
LOG_WARN
(
"best plan for remote sql is not local"
,
K
(
ret
),
K
(
plan
->
get_phy_plan_type
()));
}
}
}
if
(
OB_SUCC
(
ret
))
{
if
(
OB_SUCC
(
ret
))
{
logical_plan
=
plan
;
logical_plan
=
plan
;
LOG_TRACE
(
"succ to optimize statement"
,
"stmt"
,
stmt
.
get_sql_stmt
(),
K
(
logical_plan
->
get_optimization_cost
()));
LOG_TRACE
(
"succ to optimize statement"
,
"stmt"
,
stmt
.
get_sql_stmt
(),
K
(
logical_plan
->
get_optimization_cost
()));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录