提交 032208e3 编写于 作者: H Haojun Liao

enh(query): optimize the query perf.

上级 2621dec4
...@@ -1273,14 +1273,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1273,14 +1273,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1304,14 +1310,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1304,14 +1310,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1335,14 +1347,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1335,14 +1347,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1366,14 +1384,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1366,14 +1384,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1399,14 +1423,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1399,14 +1423,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1430,14 +1460,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1430,14 +1460,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1461,14 +1497,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1461,14 +1497,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1492,14 +1534,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1492,14 +1534,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1524,14 +1572,20 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1524,14 +1572,20 @@ 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 ((*val) == pData[i]) { // NOTE: An faster version to avoid one additional comparison with FPU.
continue; if (isMinFunc) { // min
} if (*val < pData[i]) {
*val = pData[i];
if ((*val < pData[i]) ^ isMinFunc) { if (pCtx->subsidiaries.num > 0) {
*val = pData[i]; updateTupleData(pCtx, i, pCtx->pSrcBlock, &pBuf->tuplePos);
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);
}
} }
} }
} }
...@@ -1554,7 +1608,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { ...@@ -1554,7 +1608,6 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
} }
pBuf->assign = true; pBuf->assign = true;
} else { } else {
// ignore the equivalent data value
#if 0 #if 0
if ((*val) == pData[i]) { if ((*val) == pData[i]) {
continue; continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册