Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
616539a7
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
616539a7
编写于
7月 23, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: super table order by primary key optimization
上级
84266350
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
29 addition
and
15 deletion
+29
-15
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+12
-12
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+0
-1
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+13
-1
source/libs/planner/src/planUtil.c
source/libs/planner/src/planUtil.c
+2
-1
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+2
-0
未找到文件。
source/libs/planner/src/planOptimizer.c
浏览文件 @
616539a7
...
...
@@ -997,10 +997,7 @@ static int32_t sortPriKeyOptGetScanNodesImpl(SLogicNode* pNode, bool* pNotOptimi
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
if
(
TSDB_SUPER_TABLE
!=
((
SScanLogicNode
*
)
pNode
)
->
tableType
)
{
return
nodesListMakeAppend
(
pScanNodes
,
(
SNode
*
)
pNode
);
}
break
;
return
nodesListMakeAppend
(
pScanNodes
,
(
SNode
*
)
pNode
);
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
code
=
sortPriKeyOptGetScanNodesImpl
((
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
),
pNotOptimize
,
pScanNodes
);
...
...
@@ -1040,13 +1037,16 @@ static EOrder sortPriKeyOptGetPriKeyOrder(SSortLogicNode* pSort) {
static
int32_t
sortPriKeyOptApply
(
SOptimizeContext
*
pCxt
,
SLogicSubplan
*
pLogicSubplan
,
SSortLogicNode
*
pSort
,
SNodeList
*
pScanNodes
)
{
EOrder
order
=
sortPriKeyOptGetPriKeyOrder
(
pSort
);
if
(
ORDER_DESC
==
order
)
{
SNode
*
pScanNode
=
NULL
;
FOREACH
(
pScanNode
,
pScanNodes
)
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pScanNode
;
if
(
pScan
->
scanSeq
[
0
]
>
0
)
{
TSWAP
(
pScan
->
scanSeq
[
0
],
pScan
->
scanSeq
[
1
]);
}
SNode
*
pScanNode
=
NULL
;
FOREACH
(
pScanNode
,
pScanNodes
)
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pScanNode
;
if
(
ORDER_DESC
==
order
&&
pScan
->
scanSeq
[
0
]
>
0
)
{
TSWAP
(
pScan
->
scanSeq
[
0
],
pScan
->
scanSeq
[
1
]);
}
if
(
TSDB_SUPER_TABLE
==
pScan
->
tableType
)
{
pScan
->
scanType
=
SCAN_TYPE_TABLE_MERGE
;
pScan
->
node
.
resultDataOrder
=
DATA_ORDER_LEVEL_GLOBAL
;
pScan
->
node
.
requireDataOrder
=
DATA_ORDER_LEVEL_GLOBAL
;
}
}
...
...
@@ -2191,7 +2191,7 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
!
planOptNodeListHasTbname
(
pAgg
->
pGroupKeys
))
{
return
false
;
}
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
pAgg
->
pGroupKeys
)
{
SNode
*
pGroup
=
NULL
;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
616539a7
...
...
@@ -415,7 +415,6 @@ static int32_t createScanPhysiNodeFinalize(SPhysiPlanContext* pCxt, SSubplan* pS
SScanPhysiNode
*
pScanPhysiNode
,
SPhysiNode
**
pPhyNode
)
{
int32_t
code
=
createScanCols
(
pCxt
,
pScanPhysiNode
,
pScanLogicNode
->
pScanCols
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
// Data block describe also needs to be set without scanning column, such as SELECT COUNT(*) FROM t
code
=
addDataBlockSlots
(
pCxt
,
pScanPhysiNode
->
pScanCols
,
pScanPhysiNode
->
node
.
pOutputDataBlockDesc
);
}
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
616539a7
...
...
@@ -913,13 +913,25 @@ static int32_t stbSplSplitScanNodeWithPartTags(SSplitContext* pCxt, SStableSplit
}
static
SNode
*
stbSplFindPrimaryKeyFromScan
(
SScanLogicNode
*
pScan
)
{
bool
find
=
false
;
SNode
*
pCol
=
NULL
;
FOREACH
(
pCol
,
pScan
->
pScanCols
)
{
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
((
SColumnNode
*
)
pCol
)
->
colId
)
{
find
=
true
;
break
;
}
}
if
(
!
find
)
{
return
NULL
;
}
SNode
*
pTarget
=
NULL
;
FOREACH
(
pTarget
,
pScan
->
node
.
pTargets
)
{
if
(
nodesEqualNode
(
pTarget
,
pCol
))
{
return
pCol
;
}
}
return
NULL
;
nodesListStrictAppend
(
pScan
->
node
.
pTargets
,
nodesCloneNode
(
pCol
));
return
pCol
;
}
static
int32_t
stbSplSplitMergeScanNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SScanLogicNode
*
pScan
,
...
...
source/libs/planner/src/planUtil.c
浏览文件 @
616539a7
...
...
@@ -124,7 +124,8 @@ int32_t replaceLogicNode(SLogicSubplan* pSubplan, SLogicNode* pOld, SLogicNode*
}
static
int32_t
adjustScanDataRequirement
(
SScanLogicNode
*
pScan
,
EDataOrderLevel
requirement
)
{
if
(
SCAN_TYPE_TABLE
!=
pScan
->
scanType
&&
SCAN_TYPE_TABLE_MERGE
!=
pScan
->
scanType
)
{
if
((
SCAN_TYPE_TABLE
!=
pScan
->
scanType
&&
SCAN_TYPE_TABLE_MERGE
!=
pScan
->
scanType
)
||
DATA_ORDER_LEVEL_GLOBAL
==
pScan
->
node
.
requireDataOrder
)
{
return
TSDB_CODE_SUCCESS
;
}
// The lowest sort level of scan output data is DATA_ORDER_LEVEL_IN_BLOCK
...
...
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
616539a7
...
...
@@ -53,6 +53,8 @@ TEST_F(PlanOptimizeTest, sortPrimaryKey) {
run
(
"SELECT c1 FROM t1 ORDER BY ts"
);
run
(
"SELECT c1 FROM st1 ORDER BY ts"
);
run
(
"SELECT c1 FROM t1 ORDER BY ts DESC"
);
run
(
"SELECT COUNT(*) FROM t1 INTERVAL(10S) ORDER BY _WSTART DESC"
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录