未验证 提交 b6728082 编写于 作者: S shenglian-zhou 提交者: GitHub

Merge pull request #15131 from taosdata/szhou/fix/td-17505

fix: keep only tag related scan cols and scan targets when tag scan
...@@ -1378,6 +1378,22 @@ static bool planOptNodeListHasCol(SNodeList* pKeys) { ...@@ -1378,6 +1378,22 @@ static bool planOptNodeListHasCol(SNodeList* pKeys) {
return hasCol; return hasCol;
} }
static EDealRes partTagsOptHasTbname(SNode* pNode, void* pContext) {
if (QUERY_NODE_COLUMN == nodeType(pNode)) {
if (COLUMN_TYPE_TBNAME == ((SColumnNode*)pNode)->colType) {
*(bool*)pContext = true;
return DEAL_RES_END;
}
}
return DEAL_RES_CONTINUE;
}
static bool planOptNodeListHasTbname(SNodeList* pKeys) {
bool hasCol = false;
nodesWalkExprs(pKeys, partTagsOptHasTbname, &hasCol);
return hasCol;
}
static bool partTagsIsOptimizableNode(SLogicNode* pNode) { static bool partTagsIsOptimizableNode(SLogicNode* pNode) {
return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) || return ((QUERY_NODE_LOGIC_PLAN_PARTITION == nodeType(pNode) ||
(QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && NULL != ((SAggLogicNode*)pNode)->pGroupKeys && (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && NULL != ((SAggLogicNode*)pNode)->pGroupKeys &&
...@@ -2129,7 +2145,8 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) { ...@@ -2129,7 +2145,8 @@ static bool tagScanMayBeOptimized(SLogicNode* pNode) {
} }
SAggLogicNode* pAgg = (SAggLogicNode*)(pNode->pParent); SAggLogicNode* pAgg = (SAggLogicNode*)(pNode->pParent);
if (NULL == pAgg->pGroupKeys || NULL != pAgg->pAggFuncs || planOptNodeListHasCol(pAgg->pGroupKeys)) { if (NULL == pAgg->pGroupKeys || NULL != pAgg->pAggFuncs ||
planOptNodeListHasCol(pAgg->pGroupKeys) || !planOptNodeListHasTbname(pAgg->pGroupKeys)) {
return false; return false;
} }
...@@ -2143,6 +2160,22 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp ...@@ -2143,6 +2160,22 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp
} }
pScanNode->scanType = SCAN_TYPE_TAG; pScanNode->scanType = SCAN_TYPE_TAG;
SNode* pTarget = NULL;
FOREACH(pTarget, pScanNode->node.pTargets) {
if (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)(pTarget))->colId) {
ERASE_NODE(pScanNode->node.pTargets);
break;
}
}
NODES_DESTORY_LIST(pScanNode->pScanCols);
SLogicNode* pAgg = pScanNode->node.pParent;
int32_t code = replaceLogicNode(pLogicSubplan, pAgg, (SLogicNode*)pScanNode);
if (TSDB_CODE_SUCCESS == code) {
NODES_CLEAR_LIST(pAgg->pChildren);
}
nodesDestroyNode((SNode*)pAgg);
pCxt->optimized = true; pCxt->optimized = true;
return TSDB_CODE_SUCCESS; return TSDB_CODE_SUCCESS;
} }
......
...@@ -7,6 +7,7 @@ system sh/exec.sh -n dnode1 -s start -v ...@@ -7,6 +7,7 @@ system sh/exec.sh -n dnode1 -s start -v
system sh/exec.sh -n dnode2 -s start -v system sh/exec.sh -n dnode2 -s start -v
sql connect sql connect
print =============== step1: create alter drop show user print =============== step1: create alter drop show user
sql create user u1 pass 'taosdata' sql create user u1 pass 'taosdata'
sql show users sql show users
...@@ -158,4 +159,4 @@ endi ...@@ -158,4 +159,4 @@ endi
if $system_content == $null then if $system_content == $null then
return -1 return -1
endi endi
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册