Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f2606320
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f2606320
编写于
7月 11, 2022
作者:
S
slzhou@taodata.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: tag scan optimization
上级
0fb06cbc
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
40 addition
and
4 deletion
+40
-4
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+33
-4
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+7
-0
未找到文件。
source/libs/planner/src/planOptimizer.c
浏览文件 @
f2606320
...
...
@@ -1338,9 +1338,9 @@ static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
}
static
bool
p
artTagsOptHasCol
(
SNodeList
*
pPart
Keys
)
{
static
bool
p
lanOptNodeListHasCol
(
SNodeList
*
p
Keys
)
{
bool
hasCol
=
false
;
nodesWalkExprs
(
p
Part
Keys
,
partTagsOptHasColImpl
,
&
hasCol
);
nodesWalkExprs
(
pKeys
,
partTagsOptHasColImpl
,
&
hasCol
);
return
hasCol
;
}
...
...
@@ -1383,7 +1383,7 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
return
false
;
}
return
!
p
artTagsOp
tHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
));
return
!
p
lanOptNodeLis
tHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
));
}
static
EDealRes
partTagsOptRebuildTbanmeImpl
(
SNode
**
pNode
,
void
*
pContext
)
{
...
...
@@ -2086,6 +2086,34 @@ static int32_t mergeProjectsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
return
mergeProjectsOptimizeImpl
(
pCxt
,
pLogicSubplan
,
pProjectNode
);
}
static
bool
tagScanMayBeOptimized
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
!=
nodeType
(
pNode
)
||
(
SCAN_TYPE_TAG
==
((
SScanLogicNode
*
)
pNode
)
->
scanType
))
{
return
false
;
}
if
(
NULL
==
pNode
->
pParent
||
QUERY_NODE_LOGIC_PLAN_AGG
!=
nodeType
(
pNode
->
pParent
)
||
1
!=
LIST_LENGTH
(
pNode
->
pParent
->
pChildren
))
{
return
false
;
}
SAggLogicNode
*
pAgg
=
(
SAggLogicNode
*
)(
pNode
->
pParent
);
if
(
NULL
==
pAgg
->
pGroupKeys
||
NULL
!=
pAgg
->
pAggFuncs
||
planOptNodeListHasCol
(
pAgg
->
pGroupKeys
))
{
return
false
;
}
return
true
;
}
static
int32_t
tagScanOptimize
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
)
{
SScanLogicNode
*
pScanNode
=
(
SScanLogicNode
*
)
optFindPossibleNode
(
pLogicSubplan
->
pNode
,
tagScanMayBeOptimized
);
if
(
NULL
==
pScanNode
)
{
return
TSDB_CODE_SUCCESS
;
}
pScanNode
->
scanType
=
SCAN_TYPE_TAG
;
pCxt
->
optimized
=
true
;
return
TSDB_CODE_SUCCESS
;
}
// clang-format off
static
const
SOptimizeRule
optimizeRuleSet
[]
=
{
{.
pName
=
"ScanPath"
,
.
optimizeFunc
=
scanPathOptimize
},
...
...
@@ -2098,7 +2126,8 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"EliminateSetOperator"
,
.
optimizeFunc
=
eliminateSetOpOptimize
},
{.
pName
=
"RewriteTail"
,
.
optimizeFunc
=
rewriteTailOptimize
},
{.
pName
=
"RewriteUnique"
,
.
optimizeFunc
=
rewriteUniqueOptimize
},
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
}
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
},
{.
pName
=
"TagScan"
,
.
optimizeFunc
=
tagScanOptimize
}
};
// clang-format on
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
f2606320
...
...
@@ -85,4 +85,11 @@ TEST_F(PlanOptimizeTest, eliminateProjection) {
TEST_F
(
PlanOptimizeTest
,
pushDownProjectCond
)
{
useDb
(
"root"
,
"test"
);
run
(
"select 1-abs(c1) from (select unique(c1) c1 from st1s3) where 1-c1>5 order by 1 nulls first"
);
}
TEST_F
(
PlanOptimizeTest
,
tagScan
)
{
useDb
(
"root"
,
"test"
);
run
(
"select tag1 from st1 group by tag1"
);
run
(
"select distinct tag1 from st1"
);
run
(
"select tag1*tag1 from st1 group by tag1*tag1"
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录