enh(query): improve the perf.

This commit is contained in:
Haojun Liao 2022-11-08 12:02:44 +08:00
parent 9863879951
commit 2621dec4ae
1 changed files with 18 additions and 0 deletions

View File

@ -1555,6 +1555,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
pBuf->assign = true; pBuf->assign = true;
} else { } else {
// ignore the equivalent data value // ignore the equivalent data value
#if 0
if ((*val) == pData[i]) { if ((*val) == pData[i]) {
continue; continue;
} }
@ -1565,6 +1566,23 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos); updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
} }
} }
#endif
// NOTE: An faster version to avoid one additional comparison with FPU.
if (isMinFunc) { // min
if (*val < pData[i]) {
*val = pData[i];
if (pCtx->subsidiaries.num > 0) {
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
}
}
} else { // max
if (*val > pData[i]) {
*val = pData[i];
if (pCtx->subsidiaries.num > 0) {
updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
}
}
}
} }
numOfElems += 1; numOfElems += 1;