Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
bc180e39
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看板
提交
bc180e39
编写于
11月 22, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: ins_tables optimize
上级
8b9691dd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
82 addition
and
19 deletion
+82
-19
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+2
-1
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+1
-1
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+59
-16
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+20
-1
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
bc180e39
...
...
@@ -315,7 +315,6 @@ typedef struct SScanPhysiNode {
typedef
SScanPhysiNode
STagScanPhysiNode
;
typedef
SScanPhysiNode
SBlockDistScanPhysiNode
;
typedef
SScanPhysiNode
STableCountScanPhysiNode
;
typedef
struct
SLastRowScanPhysiNode
{
SScanPhysiNode
scan
;
...
...
@@ -324,6 +323,8 @@ typedef struct SLastRowScanPhysiNode {
bool
ignoreNull
;
}
SLastRowScanPhysiNode
;
typedef
SLastRowScanPhysiNode
STableCountScanPhysiNode
;
typedef
struct
SSystemTableScanPhysiNode
{
SScanPhysiNode
scan
;
SEpSet
mgmtEpSet
;
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
bc180e39
...
...
@@ -4632,9 +4632,9 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return
logicPlanToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN
:
return
physiScanNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN
:
return
physiLastRowScanNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
:
case
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
:
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
bc180e39
...
...
@@ -2461,17 +2461,51 @@ typedef struct STbCntScanOptInfo {
SName
table
;
}
STbCntScanOptInfo
;
static
bool
tbCntScanOptIsEligibleAgg
(
SAggLogicNode
*
pAgg
)
{
if
(
1
!=
LIST_LENGTH
(
pAgg
->
pAggFuncs
)
||
NULL
!=
pAgg
->
pGroupKeys
)
{
return
false
;
static
bool
tbCntScanOptIsEligibleGroupKeys
(
SNodeList
*
pGroupKeys
)
{
if
(
NULL
==
pGroupKeys
)
{
return
true
;
}
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
pGroupKeys
)
{
SNode
*
pKey
=
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
);
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pKey
))
{
return
false
;
}
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pKey
;
if
(
0
!=
strcmp
(
pCol
->
colName
,
"db_name"
)
&&
0
!=
strcmp
(
pCol
->
colName
,
"stable_name"
))
{
return
false
;
}
}
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesListGetNode
(
pAgg
->
pAggFuncs
,
0
);
if
(
FUNCTION_TYPE_COUNT
!=
pFunc
->
funcType
)
{
return
true
;
}
static
bool
tbCntScanOptNotNullableExpr
(
SNode
*
pNode
)
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pNode
))
{
return
false
;
}
const
char
*
pColName
=
((
SColumnNode
*
)
pNode
)
->
colName
;
return
0
==
strcmp
(
pColName
,
"*"
)
||
0
==
strcmp
(
pColName
,
"db_name"
)
||
0
==
strcmp
(
pColName
,
"stable_name"
)
||
0
==
strcmp
(
pColName
,
"table_name"
);
}
static
bool
tbCntScanOptIsEligibleAggFuncs
(
SNodeList
*
pAggFuncs
)
{
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
pAggFuncs
)
{
SFunctionNode
*
pFunc
=
(
SFunctionNode
*
)
nodesListGetNode
(
pAggFuncs
,
0
);
if
(
FUNCTION_TYPE_COUNT
!=
pFunc
->
funcType
||
!
tbCntScanOptNotNullableExpr
(
nodesListGetNode
(
pFunc
->
pParameterList
,
0
)))
{
return
false
;
}
}
return
true
;
}
static
bool
tbCntScanOptIsEligibleAgg
(
SAggLogicNode
*
pAgg
)
{
return
tbCntScanOptIsEligibleGroupKeys
(
pAgg
->
pGroupKeys
)
&&
tbCntScanOptIsEligibleAggFuncs
(
pAgg
->
pAggFuncs
);
}
static
bool
tbCntScanOptGetColValFromCond
(
SOperatorNode
*
pOper
,
SColumnNode
**
pCol
,
SValueNode
**
pVal
)
{
if
(
OP_TYPE_EQUAL
!=
pOper
->
opType
)
{
return
false
;
...
...
@@ -2578,17 +2612,25 @@ static SNode* tbCntScanOptCreateTableCountFunc() {
return
(
SNode
*
)
pFunc
;
}
static
int32_t
tbCntScanOptRewriteScan
(
STbCntScanOptInfo
*
pInfo
,
SScanLogicNode
*
pScan
)
{
pScan
->
scanType
=
SCAN_TYPE_TABLE_COUNT
;
strcpy
(
pScan
->
tableName
.
dbname
,
pInfo
->
table
.
dbname
);
strcpy
(
pScan
->
tableName
.
tname
,
pInfo
->
table
.
tname
);
NODES_DESTORY_LIST
(
pScan
->
node
.
pTargets
);
NODES_DESTORY_NODE
(
pScan
->
node
.
pConditions
);
NODES_DESTORY_LIST
(
pScan
->
pScanCols
);
NODES_DESTORY_LIST
(
pScan
->
pScanPseudoCols
);
int32_t
code
=
nodesListMakeStrictAppend
(
&
pScan
->
pScanPseudoCols
,
tbCntScanOptCreateTableCountFunc
());
static
int32_t
tbCntScanOptRewriteScan
(
STbCntScanOptInfo
*
pInfo
)
{
p
Info
->
p
Scan
->
scanType
=
SCAN_TYPE_TABLE_COUNT
;
strcpy
(
p
Info
->
p
Scan
->
tableName
.
dbname
,
pInfo
->
table
.
dbname
);
strcpy
(
p
Info
->
p
Scan
->
tableName
.
tname
,
pInfo
->
table
.
tname
);
NODES_DESTORY_LIST
(
p
Info
->
p
Scan
->
node
.
pTargets
);
NODES_DESTORY_NODE
(
p
Info
->
p
Scan
->
node
.
pConditions
);
NODES_DESTORY_LIST
(
p
Info
->
p
Scan
->
pScanCols
);
NODES_DESTORY_LIST
(
p
Info
->
p
Scan
->
pScanPseudoCols
);
int32_t
code
=
nodesListMakeStrictAppend
(
&
p
Info
->
p
Scan
->
pScanPseudoCols
,
tbCntScanOptCreateTableCountFunc
());
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByRewriteExpr
(
nodesListGetNode
(
pScan
->
pScanPseudoCols
,
0
),
&
pScan
->
node
.
pTargets
);
code
=
createColumnByRewriteExpr
(
nodesListGetNode
(
pInfo
->
pScan
->
pScanPseudoCols
,
0
),
&
pInfo
->
pScan
->
node
.
pTargets
);
}
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
pInfo
->
pAgg
->
pGroupKeys
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pScan
->
pGroupTags
,
nodesCloneNode
(
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
)));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
return
code
;
}
...
...
@@ -2621,6 +2663,7 @@ static int32_t tbCntScanOptRewriteAgg(SAggLogicNode* pAgg) {
NODES_DESTORY_LIST
(
pAgg
->
pAggFuncs
);
code
=
nodesListMakeStrictAppend
(
&
pAgg
->
pAggFuncs
,
pSum
);
}
NODES_DESTORY_LIST
(
pAgg
->
pGroupKeys
);
return
code
;
}
...
...
@@ -2630,7 +2673,7 @@ static int32_t tableCountScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLo
return
TSDB_CODE_SUCCESS
;
}
int32_t
code
=
tbCntScanOptRewriteScan
(
&
info
,
info
.
pScan
);
int32_t
code
=
tbCntScanOptRewriteScan
(
&
info
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tbCntScanOptRewriteAgg
(
info
.
pAgg
);
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
bc180e39
...
...
@@ -526,6 +526,24 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu
pScan
->
ignoreNull
=
pScanLogicNode
->
igLastNull
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
}
static
int32_t
createTableCountScanPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SSubplan
*
pSubplan
,
SScanLogicNode
*
pScanLogicNode
,
SPhysiNode
**
pPhyNode
)
{
STableCountScanPhysiNode
*
pScan
=
(
STableCountScanPhysiNode
*
)
makePhysiNode
(
pCxt
,
(
SLogicNode
*
)
pScanLogicNode
,
QUERY_NODE_PHYSICAL_PLAN_TABLE_COUNT_SCAN
);
if
(
NULL
==
pScan
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pScan
->
pGroupTags
=
nodesCloneList
(
pScanLogicNode
->
pGroupTags
);
if
(
NULL
!=
pScanLogicNode
->
pGroupTags
&&
NULL
==
pScan
->
pGroupTags
)
{
nodesDestroyNode
((
SNode
*
)
pScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pScan
->
groupSort
=
pScanLogicNode
->
groupSort
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
...
...
@@ -624,8 +642,9 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan,
switch
(
pScanLogicNode
->
scanType
)
{
case
SCAN_TYPE_TAG
:
case
SCAN_TYPE_BLOCK_INFO
:
case
SCAN_TYPE_TABLE_COUNT
:
return
createSimpleScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pPhyNode
);
case
SCAN_TYPE_TABLE_COUNT
:
return
createTableCountScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pPhyNode
);
case
SCAN_TYPE_LAST_ROW
:
return
createLastRowScanPhysiNode
(
pCxt
,
pSubplan
,
pScanLogicNode
,
pPhyNode
);
case
SCAN_TYPE_TABLE
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录