diff --git a/include/os/osEnv.h b/include/os/osEnv.h index 533d989ffc40c2aae35adc02bde6080da52ac219..bc65da47a9d106c67064bdb07f85ace7332952c9 100644 --- a/include/os/osEnv.h +++ b/include/os/osEnv.h @@ -41,6 +41,7 @@ extern char tsSSE42Enable; extern char tsAVXEnable; extern char tsAVX2Enable; extern char tsFMAEnable; +extern char tsTagFilterCache; extern char configDir[]; extern char tsDataDir[]; diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 037c8a45419353864c4e6b962beb641daf3b35c1..d4849650e6c80fcab7b3831f7fa01a10d29ec50b 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -140,6 +140,7 @@ int32_t tsMaxMemUsedByInsert = 1024; float tsSelectivityRatio = 1.0; int32_t tsTagFilterResCacheSize = 1024 * 10; +char tsTagFilterCache = 0; // the maximum allowed query buffer size during query processing for each data node. // -1 no limit (default) @@ -351,6 +352,7 @@ static int32_t taosAddSystemCfg(SConfig *pCfg) { if (cfgAddBool(pCfg, "AVX2", tsAVX2Enable, 0) != 0) return -1; if (cfgAddBool(pCfg, "FMA", tsFMAEnable, 0) != 0) return -1; if (cfgAddBool(pCfg, "SIMD-builtins", tsSIMDBuiltins, 0) != 0) return -1; + if (cfgAddBool(pCfg, "tagFilterCache", tsTagFilterCache, 0) != 0) return -1; if (cfgAddInt64(pCfg, "openMax", tsOpenMax, 0, INT64_MAX, 1) != 0) return -1; if (cfgAddInt64(pCfg, "streamMax", tsStreamMax, 0, INT64_MAX, 1) != 0) return -1; @@ -731,6 +733,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64; tsSIMDBuiltins = (bool)cfgGetItem(pCfg, "SIMD-builtins")->bval; + tsTagFilterCache = (bool)cfgGetItem(pCfg, "tagFilterCache")->bval; tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval; tsMonitorInterval = cfgGetItem(pCfg, "monitorInterval")->i32; diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 1dc36f130439dfd82e61ca2164169e22cdebbd5d..d0ab2e280656c84d5170e9145655840bc273b0a5 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -2745,48 +2745,48 @@ static void resetScanBlockLastBlockDelIndex(SReaderStatus* pStatus, int32_t orde } } -static int32_t initOrderCheckInfo(SUidOrderedList* pOrderCheckInfo, STsdbReader* pReader) { - SReaderStatus* pStatus = &pReader->status; - - int32_t total = taosHashGetSize(pStatus->pTableMap); - if (total == 0) { - return TSDB_CODE_SUCCESS; - } - - if (pOrderCheckInfo->tableUidList == NULL) { - pOrderCheckInfo->currentIndex = 0; - pOrderCheckInfo->tableUidList = taosMemoryMalloc(total * sizeof(uint64_t)); - if (pOrderCheckInfo->tableUidList == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); - uint64_t uid = pOrderCheckInfo->tableUidList[0]; - pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - } else { - if (pStatus->pTableIter == NULL) { // it is the last block of a new file - pOrderCheckInfo->currentIndex = 0; - uint64_t uid = pOrderCheckInfo->tableUidList[pOrderCheckInfo->currentIndex]; - pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - - // the tableMap has already updated, let's also update the order list - if (pStatus->pTableIter == NULL) { - void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, total * sizeof(uint64_t)); - if (p == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } - - pOrderCheckInfo->tableUidList = p; - extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); - - uid = pOrderCheckInfo->tableUidList[0]; - pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); - } - } - } - - return TSDB_CODE_SUCCESS; -} +//static int32_t initOrderCheckInfo(SUidOrderedList* pOrderCheckInfo, STsdbReader* pReader) { +// SReaderStatus* pStatus = &pReader->status; +// +// int32_t total = taosHashGetSize(pStatus->pTableMap); +// if (total == 0) { +// return TSDB_CODE_SUCCESS; +// } +// +// if (pOrderCheckInfo->tableUidList == NULL) { +// pOrderCheckInfo->currentIndex = 0; +// pOrderCheckInfo->tableUidList = taosMemoryMalloc(total * sizeof(uint64_t)); +// if (pOrderCheckInfo->tableUidList == NULL) { +// return TSDB_CODE_OUT_OF_MEMORY; +// } +// +// extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); +// uint64_t uid = pOrderCheckInfo->tableUidList[0]; +// pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); +// } else { +// if (pStatus->pTableIter == NULL) { // it is the last block of a new file +// pOrderCheckInfo->currentIndex = 0; +// uint64_t uid = pOrderCheckInfo->tableUidList[pOrderCheckInfo->currentIndex]; +// pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); +// +// // the tableMap has already updated, let's also update the order list +// if (pStatus->pTableIter == NULL) { +// void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, total * sizeof(uint64_t)); +// if (p == NULL) { +// return TSDB_CODE_OUT_OF_MEMORY; +// } +// +// pOrderCheckInfo->tableUidList = p; +// extractOrderedTableUidList(pOrderCheckInfo, pStatus, pReader->order); +// +// uid = pOrderCheckInfo->tableUidList[0]; +// pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid)); +// } +// } +// } +// +// return TSDB_CODE_SUCCESS; +//} static void resetTableListIndex(SReaderStatus *pStatus) { SUidOrderedList* pList = &pStatus->uidCheckInfo; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index e65708326e39568164955722922cd93319cac4f9..d685ba206270cd4798b82980d3fa50b1a7654537 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1074,15 +1074,19 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, return code; } } else { - // try to retrieve the result from meta cache + T_MD5_CTX context = {0}; - genTagFilterDigest(pTagCond, &context); - bool acquired = false; - metaGetCachedTableUidList(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), res, &acquired); - if (acquired) { - qDebug("retrieve table uid list from cache, numOfTables:%d", (int32_t)taosArrayGetSize(res)); - goto _end; + if (tsTagFilterCache) { + // try to retrieve the result from meta cache + genTagFilterDigest(pTagCond, &context); + + bool acquired = false; + metaGetCachedTableUidList(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), res, &acquired); + if (acquired) { + qDebug("retrieve table uid list from cache, numOfTables:%d", (int32_t)taosArrayGetSize(res)); + goto _end; + } } if (!pTagCond) { // no tag filter condition exists, let's fetch all tables of this super table @@ -1118,7 +1122,9 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, memcpy(pPayload + sizeof(int32_t), taosArrayGet(res, 0), numOfTables * sizeof(uint64_t)); } - metaUidFilterCachePut(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), pPayload, size, 1); + if (tsTagFilterCache) { + metaUidFilterCachePut(metaHandle, pScanNode->suid, context.digest, tListLen(context.digest), pPayload, size, 1); + } } _end: