Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2d86f8e9
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看板
提交
2d86f8e9
编写于
11月 23, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: group by tbname optimize
上级
906fafc5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
62 addition
and
24 deletion
+62
-24
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+3
-2
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+59
-22
未找到文件。
source/libs/parser/src/parTranslater.c
浏览文件 @
2d86f8e9
...
...
@@ -7089,9 +7089,10 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) {
static
int32_t
buildUpdateTagValReq
(
STranslateContext
*
pCxt
,
SAlterTableStmt
*
pStmt
,
STableMeta
*
pTableMeta
,
SVAlterTbReq
*
pReq
)
{
SSchema
*
pSchema
=
get
Col
Schema
(
pTableMeta
,
pStmt
->
colName
);
SSchema
*
pSchema
=
get
Tag
Schema
(
pTableMeta
,
pStmt
->
colName
);
if
(
NULL
==
pSchema
)
{
return
generateSyntaxErrMsg
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
return
generateSyntaxErrMsgExt
(
&
pCxt
->
msgBuf
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
,
"Invalid tag name: %s"
,
pStmt
->
colName
);
}
pReq
->
tagName
=
strdup
(
pStmt
->
colName
);
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
2d86f8e9
...
...
@@ -292,6 +292,43 @@ static bool stbSplNeedSplitJoin(bool streamQuery, SJoinLogicNode* pJoin) {
return
true
;
}
static
SNodeList
*
stbSplGetPartKeys
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
return
((
SScanLogicNode
*
)
pNode
)
->
pGroupTags
;
}
else
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
return
((
SPartitionLogicNode
*
)
pNode
)
->
pPartitionKeys
;
}
else
{
return
NULL
;
}
}
static
bool
stbSplHasPartTbname
(
SNodeList
*
pPartKeys
)
{
if
(
NULL
==
pPartKeys
)
{
return
false
;
}
SNode
*
pPartKey
=
NULL
;
FOREACH
(
pPartKey
,
pPartKeys
)
{
if
(
QUERY_NODE_GROUPING_SET
==
nodeType
(
pPartKey
))
{
pPartKey
=
nodesListGetNode
(((
SGroupingSetNode
*
)
pPartKey
)
->
pParameterList
,
0
);
}
if
((
QUERY_NODE_FUNCTION
==
nodeType
(
pPartKey
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPartKey
)
->
funcType
)
||
(
QUERY_NODE_COLUMN
==
nodeType
(
pPartKey
)
&&
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
pPartKey
)
->
colType
))
{
return
true
;
}
}
return
false
;
}
static
bool
stbSplIsPartTableAgg
(
SAggLogicNode
*
pAgg
)
{
if
(
NULL
!=
pAgg
->
pGroupKeys
)
{
return
stbSplHasPartTbname
(
pAgg
->
pGroupKeys
);
}
if
(
1
!=
LIST_LENGTH
(
pAgg
->
node
.
pChildren
))
{
return
false
;
}
return
stbSplHasPartTbname
(
stbSplGetPartKeys
((
SLogicNode
*
)
nodesListGetNode
(
pAgg
->
node
.
pChildren
,
0
)));
}
static
bool
stbSplNeedSplit
(
bool
streamQuery
,
SLogicNode
*
pNode
)
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
...
...
@@ -301,7 +338,9 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) {
case
QUERY_NODE_LOGIC_PLAN_PARTITION
:
return
streamQuery
?
false
:
stbSplIsMultiTbScanChild
(
streamQuery
,
pNode
);
case
QUERY_NODE_LOGIC_PLAN_AGG
:
return
!
stbSplHasGatherExecFunc
(((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
return
(
!
stbSplHasGatherExecFunc
(((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
||
stbSplIsPartTableAgg
((
SAggLogicNode
*
)
pNode
))
&&
stbSplHasMultiTbScan
(
streamQuery
,
pNode
);
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
stbSplNeedSplitWindow
(
streamQuery
,
pNode
);
case
QUERY_NODE_LOGIC_PLAN_SORT
:
...
...
@@ -676,27 +715,8 @@ static int32_t stbSplSplitState(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
}
}
static
SNodeList
*
stbSplGetPartKeys
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
return
((
SScanLogicNode
*
)
pNode
)
->
pGroupTags
;
}
else
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
return
((
SPartitionLogicNode
*
)
pNode
)
->
pPartitionKeys
;
}
else
{
return
NULL
;
}
}
static
bool
stbSplIsPartTbanme
(
SNodeList
*
pPartKeys
)
{
if
(
NULL
==
pPartKeys
||
1
!=
LIST_LENGTH
(
pPartKeys
))
{
return
false
;
}
SNode
*
pPartKey
=
nodesListGetNode
(
pPartKeys
,
0
);
return
(
QUERY_NODE_FUNCTION
==
nodeType
(
pPartKey
)
&&
FUNCTION_TYPE_TBNAME
==
((
SFunctionNode
*
)
pPartKey
)
->
funcType
)
||
(
QUERY_NODE_COLUMN
==
nodeType
(
pPartKey
)
&&
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
pPartKey
)
->
colType
);
}
static
bool
stbSplIsPartTableWinodw
(
SWindowLogicNode
*
pWindow
)
{
return
stbSpl
IsPartTban
me
(
stbSplGetPartKeys
((
SLogicNode
*
)
nodesListGetNode
(
pWindow
->
node
.
pChildren
,
0
)));
return
stbSpl
HasPartTbna
me
(
stbSplGetPartKeys
((
SLogicNode
*
)
nodesListGetNode
(
pWindow
->
node
.
pChildren
,
0
)));
}
static
int32_t
stbSplSplitWindowForCrossTable
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
...
...
@@ -797,7 +817,17 @@ static int32_t stbSplCreatePartAggNode(SAggLogicNode* pMergeAgg, SLogicNode** pO
return
code
;
}
static
int32_t
stbSplSplitAggNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
static
int32_t
stbSplSplitAggNodeForPartTable
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
int32_t
code
=
splCreateExchangeNodeForSubplan
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
SUBPLAN_TYPE_MERGE
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
(
SNode
*
)
splCreateScanSubplan
(
pCxt
,
pInfo
->
pSplitNode
,
SPLIT_FLAG_STABLE_SPLIT
));
}
++
(
pCxt
->
groupId
);
return
code
;
}
static
int32_t
stbSplSplitAggNodeForCrossTable
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartAgg
=
NULL
;
int32_t
code
=
stbSplCreatePartAggNode
((
SAggLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartAgg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -812,6 +842,13 @@ static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo)
return
code
;
}
static
int32_t
stbSplSplitAggNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
if
(
stbSplIsPartTableAgg
((
SAggLogicNode
*
)
pInfo
->
pSplitNode
))
{
return
stbSplSplitAggNodeForPartTable
(
pCxt
,
pInfo
);
}
return
stbSplSplitAggNodeForCrossTable
(
pCxt
,
pInfo
);
}
static
SNode
*
stbSplCreateColumnNode
(
SExprNode
*
pExpr
)
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录