diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index e1b7cff8be8c551d0985ea293fcaff3b52f0d97b..650bb6bb4e6acd013bcfe3e9a43e67309ce0f570 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -67,6 +67,8 @@ extern int32_t tsCompressColData; extern int32_t tsMaxNumOfDistinctResults; extern char tsTempDir[]; extern int32_t tsShortcutFlag; +extern int32_t tsMaxSqlGroups; +extern int8_t tsSortWhenGroupBy; // query buffer management extern int32_t tsQueryBufferSize; // maximum allowed usage buffer size in MB for each data node during query processing diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 77540cd0b61ed54c461fa44984abd20d507a74ab..d9b254a26ab46932a6c413f3b0324a2b8c867ac4 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -118,6 +118,12 @@ int32_t tsRetryStreamCompDelay = 30 * 60 * 1000; // The delayed computing ration. 10% of the whole computing time window by default. float tsStreamComputDelayRatio = 0.1f; +// max supported groups for group by clause / interval clause +int32_t tsMaxSqlGroups = 1000000; + +// order by first group by column when group by +int8_t tsSortWhenGroupBy = 1; + int32_t tsProjectExecInterval = 10000; // every 10sec, the projection will be executed once int64_t tsMaxRetentWindow = 24 * 3600L; // maximum time window tolerance @@ -1772,6 +1778,25 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); + cfg.option = "maxSqlGroups"; + cfg.ptr = &tsMaxSqlGroups; + cfg.valType = TAOS_CFG_VTYPE_INT32; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; + cfg.minValue = 500000; + cfg.maxValue = 10000000; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + + cfg.option = "sortWhenGroupBy"; + cfg.ptr = &tsSortWhenGroupBy; + cfg.valType = TAOS_CFG_VTYPE_INT8; + cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG; + cfg.minValue = 0; + cfg.maxValue = 1; + cfg.ptrLength = 0; + cfg.unitType = TAOS_CFG_UTYPE_NONE; + taosInitConfigOption(cfg); + #ifdef TD_TSZ // lossy compress cfg.option = "lossyColumns"; diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index bb9ded8e40258060cc6a80c4bb0e2ecd42bc74a0..47334ab81e4307f3034022d79a3857e5150dc594 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -621,7 +621,7 @@ static SResultRow* doSetResultOutBufByKey(SQueryRuntimeEnv* pRuntimeEnv, SResult } // too many time window in query - if (pResultRowInfo->size > MAX_INTERVAL_TIME_WINDOW) { + if (pResultRowInfo->size > tsMaxSqlGroups) { longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW); } @@ -7607,7 +7607,7 @@ static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) { } initGroupResInfo(&pRuntimeEnv->groupResInfo, &pInfo->binfo.resultRowInfo); - if (!pRuntimeEnv->pQueryAttr->stableQuery) { + if (!pRuntimeEnv->pQueryAttr->stableQuery && tsSortWhenGroupBy) { sortGroupResByOrderList(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pInfo->binfo.pRes, pInfo->binfo.pCtx); } diff --git a/src/util/inc/tconfig.h b/src/util/inc/tconfig.h index 872da82a8e16549facd03fb3249b03b150a8f842..a2c293772213fe804bc49fb2b74b9cc557dca269 100644 --- a/src/util/inc/tconfig.h +++ b/src/util/inc/tconfig.h @@ -20,7 +20,7 @@ extern "C" { #endif -#define TSDB_CFG_MAX_NUM 134 +#define TSDB_CFG_MAX_NUM 136 #define TSDB_CFG_PRINT_LEN 23 #define TSDB_CFG_OPTION_LEN 24 #define TSDB_CFG_VALUE_LEN 41