Skip to content

Commit

Permalink
Merge pull request #21567 from wangjiaming0909/fix/3.0/TD-24525
Browse files Browse the repository at this point in the history
fix: prevent projectoperator scanning all rows when limit with no group
  • Loading branch information
dapan1121 authored Jun 8, 2023
2 parents 87d91bf + 3cb64f3 commit a9ed1f6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/libs/executor/src/groupoperator.c
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,8 @@ uint64_t calcGroupId(char* pData, int32_t len) {
// NOTE: only extract the initial 8 bytes of the final MD5 digest
uint64_t id = 0;
memcpy(&id, context.digest, sizeof(uint64_t));
if (0 == id)
memcpy(&id, context.digest + 8, sizeof(uint64_t));
return id;
}

Expand Down
5 changes: 5 additions & 0 deletions source/libs/executor/src/joinoperator.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ void destroyMergeJoinOperator(void* param) {
}
nodesDestroyNode(pJoinOperator->pCondAfterMerge);

taosArrayDestroy(pJoinOperator->rowCtx.leftCreatedBlocks);
taosArrayDestroy(pJoinOperator->rowCtx.rightCreatedBlocks);
taosArrayDestroy(pJoinOperator->rowCtx.leftRowLocations);
taosArrayDestroy(pJoinOperator->rowCtx.rightRowLocations);

pJoinOperator->pRes = blockDataDestroy(pJoinOperator->pRes);
taosMemoryFreeClear(param);
}
Expand Down
2 changes: 2 additions & 0 deletions source/libs/executor/src/projectoperator.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS
} else {
if (limitReached && (pLimitInfo->slimit.limit >= 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) {
setOperatorCompleted(pOperator);
} else if (limitReached && groupId == 0) {
setOperatorCompleted(pOperator);
}
}

Expand Down

0 comments on commit a9ed1f6

Please sign in to comment.