Merge pull request #17442 from taosdata/fix/TD-19443-V30
fix(query): improve performance for first function x10 quickly
This commit is contained in:
commit
7cdfade1ae
|
@ -118,6 +118,7 @@ int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pB
|
||||||
int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
|
||||||
int32_t getFirstLastInfoSize(int32_t resBytes);
|
int32_t getFirstLastInfoSize(int32_t resBytes);
|
||||||
|
EFuncDataRequired firstDynDataReq(void* pRes, STimeWindow* pTimeWindow);
|
||||||
EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow);
|
EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow);
|
||||||
|
|
||||||
int32_t lastRowFunction(SqlFunctionCtx* pCtx);
|
int32_t lastRowFunction(SqlFunctionCtx* pCtx);
|
||||||
|
|
|
@ -2431,6 +2431,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.type = FUNCTION_TYPE_FIRST,
|
.type = FUNCTION_TYPE_FIRST,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
||||||
.translateFunc = translateFirstLast,
|
.translateFunc = translateFirstLast,
|
||||||
|
.dynDataRequiredFunc = firstDynDataReq,
|
||||||
.getEnvFunc = getFirstLastFuncEnv,
|
.getEnvFunc = getFirstLastFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = firstFunction,
|
.processFunc = firstFunction,
|
||||||
|
@ -2445,6 +2446,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
|
||||||
.type = FUNCTION_TYPE_FIRST_PARTIAL,
|
.type = FUNCTION_TYPE_FIRST_PARTIAL,
|
||||||
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
.classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC,
|
||||||
.translateFunc = translateFirstLastPartial,
|
.translateFunc = translateFirstLastPartial,
|
||||||
|
.dynDataRequiredFunc = firstDynDataReq,
|
||||||
.getEnvFunc = getFirstLastFuncEnv,
|
.getEnvFunc = getFirstLastFuncEnv,
|
||||||
.initFunc = functionSetup,
|
.initFunc = functionSetup,
|
||||||
.processFunc = firstFunction,
|
.processFunc = firstFunction,
|
||||||
|
|
|
@ -2720,6 +2720,22 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EFuncDataRequired firstDynDataReq(void* pRes, STimeWindow* pTimeWindow) {
|
||||||
|
SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*)pRes;
|
||||||
|
|
||||||
|
// not initialized yet, data is required
|
||||||
|
if (pEntry == NULL) {
|
||||||
|
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
SFirstLastRes* pResult = GET_ROWCELL_INTERBUF(pEntry);
|
||||||
|
if (pResult->hasResult && pResult->ts <= pTimeWindow->skey) {
|
||||||
|
return FUNC_DATA_REQUIRED_NOT_LOAD;
|
||||||
|
} else {
|
||||||
|
return FUNC_DATA_REQUIRED_DATA_LOAD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow) {
|
EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow) {
|
||||||
SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*)pRes;
|
SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*)pRes;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue