fix: selectivity

This commit is contained in:
Liu Jicong 2022-12-29 14:43:45 +08:00
parent 7721353b6b
commit 93cf8e0186
1 changed files with 21 additions and 21 deletions

View File

@ -818,8 +818,8 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
return; return;
} }
if (pCtx->saveHandle.pBuf != NULL) { if ((pCtx->saveHandle.pBuf != NULL && pTuplePos->pageId != -1) ||
if (pTuplePos->pageId != -1) { (pCtx->saveHandle.pState && pTuplePos->streamTupleKey.ts > 0)) {
int32_t numOfCols = pCtx->subsidiaries.num; int32_t numOfCols = pCtx->subsidiaries.num;
const char* p = loadTupleData(pCtx, pTuplePos); const char* p = loadTupleData(pCtx, pTuplePos);
@ -841,7 +841,6 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
pStart += pDstCol->info.bytes; pStart += pDstCol->info.bytes;
} }
} }
}
} }
void releaseSource(STuplePos* pPos) { void releaseSource(STuplePos* pPos) {
@ -2071,8 +2070,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function. // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
// we will use this opt implementation in an new version that is only available in scan subplan // function. we will use this opt implementation in an new version that is only available in scan subplan
#if 0 #if 0
if (blockDataOrder == TSDB_ORDER_ASC) { if (blockDataOrder == TSDB_ORDER_ASC) {
// filter according to current result firstly // filter according to current result firstly
@ -2179,7 +2178,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC; int32_t blockDataOrder = (startKey <= endKey) ? TSDB_ORDER_ASC : TSDB_ORDER_DESC;
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function. // please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
// function.
#if 0 #if 0
if (blockDataOrder == TSDB_ORDER_ASC) { if (blockDataOrder == TSDB_ORDER_ASC) {
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) { for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {