Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f797e60f
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
未验证
提交
f797e60f
编写于
7月 12, 2022
作者:
S
shenglian-zhou
提交者:
GitHub
7月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14777 from taosdata/szhou/td-17001
feat: tag scan optimization
上级
2f64f0dc
5e50bf8d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
43 addition
and
4 deletion
+43
-4
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+36
-4
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+7
-0
未找到文件。
source/libs/planner/src/planOptimizer.c
浏览文件 @
f797e60f
...
@@ -1364,9 +1364,9 @@ static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) {
...
@@ -1364,9 +1364,9 @@ static EDealRes partTagsOptHasColImpl(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
bool
p
artTagsOptHasCol
(
SNodeList
*
pPart
Keys
)
{
static
bool
p
lanOptNodeListHasCol
(
SNodeList
*
p
Keys
)
{
bool
hasCol
=
false
;
bool
hasCol
=
false
;
nodesWalkExprs
(
p
Part
Keys
,
partTagsOptHasColImpl
,
&
hasCol
);
nodesWalkExprs
(
pKeys
,
partTagsOptHasColImpl
,
&
hasCol
);
return
hasCol
;
return
hasCol
;
}
}
...
@@ -1409,7 +1409,7 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
...
@@ -1409,7 +1409,7 @@ static bool partTagsOptMayBeOptimized(SLogicNode* pNode) {
return
false
;
return
false
;
}
}
return
!
p
artTagsOp
tHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
));
return
!
p
lanOptNodeLis
tHasCol
(
partTagsGetPartKeys
(
pNode
))
&&
partTagsOptAreSupportedFuncs
(
partTagsGetFuncs
(
pNode
));
}
}
static
int32_t
partTagsOptRebuildTbanme
(
SNodeList
*
pPartKeys
)
{
static
int32_t
partTagsOptRebuildTbanme
(
SNodeList
*
pPartKeys
)
{
...
@@ -2096,6 +2096,37 @@ static int32_t mergeProjectsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
...
@@ -2096,6 +2096,37 @@ static int32_t mergeProjectsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
return
mergeProjectsOptimizeImpl
(
pCxt
,
pLogicSubplan
,
pProjectNode
);
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
;
}
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
if
(
NULL
!=
pScan
->
pScanCols
)
{
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
// clang-format off
static
const
SOptimizeRule
optimizeRuleSet
[]
=
{
static
const
SOptimizeRule
optimizeRuleSet
[]
=
{
{.
pName
=
"ScanPath"
,
.
optimizeFunc
=
scanPathOptimize
},
{.
pName
=
"ScanPath"
,
.
optimizeFunc
=
scanPathOptimize
},
...
@@ -2108,7 +2139,8 @@ static const SOptimizeRule optimizeRuleSet[] = {
...
@@ -2108,7 +2139,8 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"EliminateSetOperator"
,
.
optimizeFunc
=
eliminateSetOpOptimize
},
{.
pName
=
"EliminateSetOperator"
,
.
optimizeFunc
=
eliminateSetOpOptimize
},
{.
pName
=
"RewriteTail"
,
.
optimizeFunc
=
rewriteTailOptimize
},
{.
pName
=
"RewriteTail"
,
.
optimizeFunc
=
rewriteTailOptimize
},
{.
pName
=
"RewriteUnique"
,
.
optimizeFunc
=
rewriteUniqueOptimize
},
{.
pName
=
"RewriteUnique"
,
.
optimizeFunc
=
rewriteUniqueOptimize
},
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
}
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
},
{.
pName
=
"TagScan"
,
.
optimizeFunc
=
tagScanOptimize
}
};
};
// clang-format on
// clang-format on
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
f797e60f
...
@@ -88,3 +88,10 @@ TEST_F(PlanOptimizeTest, pushDownProjectCond) {
...
@@ -88,3 +88,10 @@ TEST_F(PlanOptimizeTest, pushDownProjectCond) {
useDb
(
"root"
,
"test"
);
useDb
(
"root"
,
"test"
);
run
(
"select 1-abs(c1) from (select unique(c1) c1 from st1s3) where 1-c1>5 order by 1 nulls first"
);
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录