Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
629ab2b8
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,发现更多精彩内容 >>
提交
629ab2b8
编写于
5月 15, 2023
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: extract tag equal condition
上级
51d70ca2
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
103 addition
and
6 deletion
+103
-6
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+2
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+1
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+14
-4
source/libs/nodes/src/nodesMsgFuncs.c
source/libs/nodes/src/nodesMsgFuncs.c
+8
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+73
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+3
-0
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
629ab2b8
...
...
@@ -112,6 +112,7 @@ typedef struct SJoinLogicNode {
SNode
*
pOnConditions
;
bool
isSingleTableJoin
;
EOrder
inputTsOrder
;
SNode
*
pTagEqualConditions
;
}
SJoinLogicNode
;
typedef
struct
SAggLogicNode
{
...
...
@@ -405,6 +406,7 @@ typedef struct SSortMergeJoinPhysiNode {
SNode
*
pOnConditions
;
SNodeList
*
pTargets
;
EOrder
inputTsOrder
;
SNode
*
pTagEqualCondtions
;
}
SSortMergeJoinPhysiNode
;
typedef
struct
SAggPhysiNode
{
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
629ab2b8
...
...
@@ -401,6 +401,7 @@ static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
COPY_SCALAR_FIELD
(
joinType
);
CLONE_NODE_FIELD
(
pMergeCondition
);
CLONE_NODE_FIELD
(
pOnConditions
);
CLONE_NODE_FIELD
(
pTagEqualConditions
);
COPY_SCALAR_FIELD
(
isSingleTableJoin
);
COPY_SCALAR_FIELD
(
inputTsOrder
);
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
629ab2b8
...
...
@@ -1416,6 +1416,7 @@ static int32_t jsonToLogicPlan(const SJson* pJson, void* pObj) {
static
const
char
*
jkJoinLogicPlanJoinType
=
"JoinType"
;
static
const
char
*
jkJoinLogicPlanOnConditions
=
"OnConditions"
;
static
const
char
*
jkJoinLogicPlanMergeCondition
=
"MergeConditions"
;
static
const
char
*
jkJoinLogicPlanTagEqualConditions
=
"TagEqualConditions"
;
static
int32_t
logicJoinNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SJoinLogicNode
*
pNode
=
(
const
SJoinLogicNode
*
)
pObj
;
...
...
@@ -1430,7 +1431,9 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlanOnConditions
,
nodeToJson
,
pNode
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlanTagEqualConditions
,
nodeToJson
,
pNode
->
pTagEqualConditions
);
}
return
code
;
}
...
...
@@ -1447,7 +1450,9 @@ static int32_t jsonToLogicJoinNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlanOnConditions
,
&
pNode
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlanTagEqualConditions
,
&
pNode
->
pTagEqualConditions
);
}
return
code
;
}
...
...
@@ -1878,6 +1883,7 @@ static const char* jkJoinPhysiPlanInputTsOrder = "InputTsOrder";
static
const
char
*
jkJoinPhysiPlanMergeCondition
=
"MergeCondition"
;
static
const
char
*
jkJoinPhysiPlanOnConditions
=
"OnConditions"
;
static
const
char
*
jkJoinPhysiPlanTargets
=
"Targets"
;
static
const
char
*
jkJoinPhysiPlanTagEqualConditions
=
"TagEqualConditions"
;
static
int32_t
physiJoinNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSortMergeJoinPhysiNode
*
pNode
=
(
const
SSortMergeJoinPhysiNode
*
)
pObj
;
...
...
@@ -1898,7 +1904,9 @@ static int32_t physiJoinNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkJoinPhysiPlanTargets
,
pNode
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinPhysiPlanTagEqualConditions
,
nodeToJson
,
pNode
->
pTagEqualCondtions
);
}
return
code
;
}
...
...
@@ -1921,7 +1929,9 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkJoinPhysiPlanTargets
,
&
pNode
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlanTagEqualConditions
,
&
pNode
->
pTagEqualCondtions
);
}
return
code
;
}
...
...
source/libs/nodes/src/nodesMsgFuncs.c
浏览文件 @
629ab2b8
...
...
@@ -2317,7 +2317,8 @@ enum {
PHY_SORT_MERGE_JOIN_CODE_MERGE_CONDITION
,
PHY_SORT_MERGE_JOIN_CODE_ON_CONDITIONS
,
PHY_SORT_MERGE_JOIN_CODE_TARGETS
,
PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
,
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
};
static
int32_t
physiJoinNodeToMsg
(
const
void
*
pObj
,
STlvEncoder
*
pEncoder
)
{
...
...
@@ -2339,7 +2340,9 @@ static int32_t physiJoinNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tlvEncodeEnum
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
,
pNode
->
inputTsOrder
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tlvEncodeObj
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
,
nodeToMsg
,
pNode
->
pTagEqualCondtions
);
}
return
code
;
}
...
...
@@ -2368,6 +2371,9 @@ static int32_t msgToPhysiJoinNode(STlvDecoder* pDecoder, void* pObj) {
case
PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
:
code
=
tlvDecodeEnum
(
pTlv
,
&
pNode
->
inputTsOrder
,
sizeof
(
pNode
->
inputTsOrder
));
break
;
case
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
:
code
=
msgToNodeFromTlv
(
pTlv
,
(
void
**
)
&
pNode
->
pTagEqualCondtions
);
break
;
default:
break
;
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
629ab2b8
...
...
@@ -1072,6 +1072,7 @@ void nodesDestroyNode(SNode* pNode) {
destroyLogicNode
((
SLogicNode
*
)
pLogicNode
);
nodesDestroyNode
(
pLogicNode
->
pMergeCondition
);
nodesDestroyNode
(
pLogicNode
->
pOnConditions
);
nodesDestroyNode
(
pLogicNode
->
pTagEqualConditions
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_AGG
:
{
...
...
@@ -1204,6 +1205,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pPhyNode
->
pMergeCondition
);
nodesDestroyNode
(
pPhyNode
->
pOnConditions
);
nodesDestroyList
(
pPhyNode
->
pTargets
);
nodesDestroyNode
(
pPhyNode
->
pTagEqualCondtions
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG
:
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
629ab2b8
...
...
@@ -740,6 +740,75 @@ static int32_t pushDownCondOptJoinExtractMergeCond(SOptimizeContext* pCxt, SJoin
return
code
;
}
static
bool
pushDownCondOptIsTag
(
SNode
*
pNode
,
SNodeList
*
pTableCols
)
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pNode
))
{
return
false
;
}
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
COLUMN_TYPE_TAG
!=
pCol
->
colType
)
{
return
false
;
}
return
pushDownCondOptBelongThisTable
(
pNode
,
pTableCols
);
}
static
bool
pushDownCondOptIsTagEqualCond
(
SJoinLogicNode
*
pJoin
,
SNode
*
pCond
)
{
if
(
QUERY_NODE_OPERATOR
!=
nodeType
(
pCond
))
{
return
false
;
}
SOperatorNode
*
pOper
=
(
SOperatorNode
*
)
pCond
;
if
(
OP_TYPE_EQUAL
!=
pOper
->
opType
)
{
return
false
;
}
SNodeList
*
pLeftCols
=
((
SLogicNode
*
)
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
0
))
->
pTargets
;
SNodeList
*
pRightCols
=
((
SLogicNode
*
)
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
))
->
pTargets
;
if
(
pushDownCondOptIsTag
(
pOper
->
pLeft
,
pLeftCols
))
{
return
pushDownCondOptIsTag
(
pOper
->
pRight
,
pRightCols
);
}
else
if
(
pushDownCondOptIsTag
(
pOper
->
pLeft
,
pRightCols
))
{
return
pushDownCondOptIsTag
(
pOper
->
pRight
,
pLeftCols
);
}
return
false
;
}
static
int32_t
pushDownCondOptJoinExtractTagEqualLogicCond
(
SJoinLogicNode
*
pJoin
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)(
pJoin
->
pOnConditions
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
pTagEqualConds
=
NULL
;
SNode
*
pCond
=
NULL
;
FOREACH
(
pCond
,
pLogicCond
->
pParameterList
)
{
if
(
pushDownCondOptIsTagEqualCond
(
pJoin
,
pCond
))
{
code
=
nodesListMakeAppend
(
&
pTagEqualConds
,
nodesCloneNode
(
pCond
));
}
}
SNode
*
pTempTagEqCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempTagEqCond
,
&
pTagEqualConds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoin
->
pTagEqualConditions
=
pTempTagEqCond
;
return
TSDB_CODE_SUCCESS
;
}
else
{
nodesDestroyList
(
pTagEqualConds
);
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
pushDownCondOptJoinExtractTagEqualCond
(
SOptimizeContext
*
pCxt
,
SJoinLogicNode
*
pJoin
)
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pJoin
->
pOnConditions
)
&&
LOGIC_COND_TYPE_AND
==
((
SLogicConditionNode
*
)(
pJoin
->
pOnConditions
))
->
condType
)
{
return
pushDownCondOptJoinExtractTagEqualLogicCond
(
pJoin
);
}
if
(
pushDownCondOptIsTagEqualCond
(
pJoin
,
pJoin
->
pOnConditions
))
{
pJoin
->
pTagEqualConditions
=
nodesCloneNode
(
pJoin
->
pOnConditions
);
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
pushDownCondOptDealJoin
(
SOptimizeContext
*
pCxt
,
SJoinLogicNode
*
pJoin
)
{
if
(
OPTIMIZE_FLAG_TEST_MASK
(
pJoin
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_PUSH_DOWN_CONDE
))
{
return
TSDB_CODE_SUCCESS
;
...
...
@@ -774,6 +843,10 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p
code
=
pushDownCondOptJoinExtractMergeCond
(
pCxt
,
pJoin
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushDownCondOptJoinExtractTagEqualCond
(
pCxt
,
pJoin
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
OPTIMIZE_FLAG_SET_MASK
(
pJoin
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_PUSH_DOWN_CONDE
);
pCxt
->
optimized
=
true
;
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
629ab2b8
...
...
@@ -705,6 +705,9 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
pJoinLogicNode
->
pOnConditions
,
&
pJoin
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pJoinLogicNode
->
pTagEqualConditions
)
{
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
pTagEqualConditions
,
&
pJoin
->
pTagEqualCondtions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pJoinLogicNode
,
(
SPhysiNode
*
)
pJoin
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录