diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 07e5f75e87904e8b7998717224214d2f15dccce0..d57175d31ba9f5d5ba97149e9f8666e69c3bbcf0 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -101,6 +101,7 @@ typedef struct SQueryExecMetric { int64_t ctgStart; // start to parse, us int64_t ctgEnd; // end to parse, us int64_t semanticEnd; + int64_t planEnd; int64_t execEnd; int64_t send; // start to send to server, us int64_t rsp; // receive response from server, us diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 1342e89b523ac0a2ae2fc1eca7584aff2a340f1d..9117287b32034850709a1ae5980554c9db5bd772 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -83,11 +83,12 @@ static void deregisterRequest(SRequestObj *pRequest) { pRequest->metric.execEnd - pRequest->metric.semanticEnd); atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration); } else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) { - tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 "us, exec:%" PRId64 "us", + tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 "us, planner:%" PRId64 "us, exec:%" PRId64 "us", duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, - pRequest->metric.execEnd - pRequest->metric.semanticEnd); + pRequest->metric.planEnd - pRequest->metric.semanticEnd, + nowUs - pRequest->metric.semanticEnd); atomic_add_fetch_64((int64_t *)&pActivity->queryElapsedTime, duration); } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 2baca1288fe086388cc3e5a424ab289586a864f5..97429e099b7610b7660b6b3c2f1148c0ec5c44ea 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1030,6 +1030,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM pRequest->body.subplanNum = pDag->numOfSubplans; } + pRequest->metric.planEnd = taosGetTimestampUs(); + if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) { SArray* pNodeList = NULL; buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 45ab3903a9e9eb6df844244b6fc7cd8d009ebd47..120b33dd133aff17c73b965019e3c54f5630b71a 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1665,7 +1665,10 @@ static bool eliminateProjOptMayBeOptimized(SLogicNode* pNode) { return false; } - if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { + // Super table scan requires project operator to merge packets to improve performance. + if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) || + (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0)) && + TSDB_SUPER_TABLE == ((SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0))->tableType)) { return false; } diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp index f904643be91298fd8bcd1164334663af32851e98..96f7d29230bafc94639be35fcc56550c029ffbac 100644 --- a/source/libs/planner/test/planTestUtil.cpp +++ b/source/libs/planner/test/planTestUtil.cpp @@ -278,12 +278,12 @@ class PlannerTestBaseImpl { } void dump(DumpModule module) { + cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; + if (DUMP_MODULE_NOTHING == module) { return; } - cout << "========================================== " << sqlNo_ << " sql : [" << stmtEnv_.sql_ << "]" << endl; - if (DUMP_MODULE_ALL == module || DUMP_MODULE_PARSER == module) { if (res_.prepareAst_.empty()) { cout << "+++++++++++++++++++++syntax tree : " << endl;