From e56f88d8b88572c08e0d2c474a19914d7370f5e5 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 3 Jan 2022 16:23:06 +0800 Subject: [PATCH] [TS-802](query): first last optimition of query performance --- src/query/src/qExecutor.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 6346e74308..d2d61f140c 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -5604,6 +5604,18 @@ static int32_t getTableScanOrder(STableScanInfo* pTableScanInfo) { return pTableScanInfo->order; } +// check all SQLFunctionCtx is completed +static bool allCtxCompleted(SOperatorInfo* pOperator, SQLFunctionCtx* pCtx) { + // only one false, return false + for(int32_t i = 0; i < pOperator->numOfOutput; i++) { + if(pCtx[i].resultInfo == NULL) + return false; + if(!pCtx[i].resultInfo->complete) + return false; + } + return true; +} + // this is a blocking operator static SSDataBlock* doAggregate(void* param, bool* newgroup) { SOperatorInfo* pOperator = (SOperatorInfo*) param; @@ -5642,6 +5654,9 @@ static SSDataBlock* doAggregate(void* param, bool* newgroup) { // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); doAggregateImpl(pOperator, pQueryAttr->window.skey, pInfo->pCtx, pBlock); + // if all pCtx is completed, then query should be over + if(allCtxCompleted(pOperator, pInfo->pCtx)) + break; } doSetOperatorCompleted(pOperator); -- GitLab