diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 38ae56eb241139cf33b56213832c8c6797ba4d1c..9e9b2056b19ea1bb2f593bbc79d28aa95edcd552 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -84,7 +84,7 @@ int8_t tsTscEnableRecordSql = 0; // the maximum number of results for projection query on super table that are returned from // one virtual node, to order according to timestamp -int32_t tsMaxNumOfOrderedResults = 100000; +int32_t tsMaxNumOfOrderedResults = 1000000; // 10 ms for sliding time, the value will changed in case of time precision changed int32_t tsMinSlidingTime = 10; @@ -1017,8 +1017,8 @@ static void doInitGlobalConfig(void) { cfg.ptr = &tsMaxNumOfOrderedResults; cfg.valType = TAOS_CFG_VTYPE_INT32; cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = TSDB_MAX_SQL_LEN; - cfg.maxValue = TSDB_MAX_ALLOWED_SQL_LEN; + cfg.minValue = 100000; + cfg.maxValue = 100000000; cfg.ptrLength = 0; cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); diff --git a/src/query/src/qTsbuf.c b/src/query/src/qTsbuf.c index 4cf05dd2c7703c7879410faa2632e17a16d595fd..99572f6e9345b933434e3685ecb79750a04388fc 100644 --- a/src/query/src/qTsbuf.c +++ b/src/query/src/qTsbuf.c @@ -375,6 +375,16 @@ STSBlock* readDataFromDisk(STSBuf* pTSBuf, int32_t order, bool decomp) { sz = fread(pBlock->payload, (size_t)pBlock->compLen, 1, pTSBuf->f); if (decomp) { + if (pBlock->numOfElem * TSDB_KEYSIZE > pTSBuf->tsData.allocSize) { + pTSBuf->tsData.rawBuf = realloc(pTSBuf->tsData.rawBuf, pBlock->numOfElem * TSDB_KEYSIZE); + pTSBuf->tsData.allocSize = pBlock->numOfElem * TSDB_KEYSIZE; + } + + if (pBlock->numOfElem * TSDB_KEYSIZE > pTSBuf->bufSize) { + pTSBuf->assistBuf = realloc(pTSBuf->assistBuf, pBlock->numOfElem * TSDB_KEYSIZE); + pTSBuf->bufSize = pBlock->numOfElem * TSDB_KEYSIZE; + } + pTSBuf->tsData.len = tsDecompressTimestamp(pBlock->payload, pBlock->compLen, pBlock->numOfElem, pTSBuf->tsData.rawBuf, pTSBuf->tsData.allocSize, TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize); @@ -471,7 +481,7 @@ void tsBufAppend(STSBuf* pTSBuf, int32_t id, tVariant* tag, const char* pData, i // the size of raw data exceeds the size of the default prepared buffer, so // during getBufBlock, the output buffer needs to be large enough. - if (ptsData->len >= ptsData->threshold) { + if (ptsData->len >= ptsData->threshold - TSDB_KEYSIZE) { writeDataToDisk(pTSBuf); shrinkBuffer(ptsData); } @@ -603,6 +613,10 @@ static void tsBufGetBlock(STSBuf* pTSBuf, int32_t groupIndex, int32_t blockIndex expandBuffer(&pTSBuf->tsData, (int32_t)s); } + if (s > pTSBuf->bufSize) { + pTSBuf->assistBuf = realloc(pTSBuf->assistBuf, s); + pTSBuf->bufSize = (int32_t)s; + } pTSBuf->tsData.len = tsDecompressTimestamp(pBlock->payload, pBlock->compLen, pBlock->numOfElem, pTSBuf->tsData.rawBuf, pTSBuf->tsData.allocSize, TWO_STAGE_COMP, pTSBuf->assistBuf, pTSBuf->bufSize);