enh: optimize last pruning logic
This commit is contained in:
parent
528dcf86eb
commit
6277b2564b
|
@ -332,7 +332,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
// retrieve the only one last row of all tables in the uid list.
|
||||
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_SINGLE)) {
|
||||
int64_t st = taosGetTimestampUs();
|
||||
int64_t totalMinTs = INT64_MAX;
|
||||
int64_t totalLastTs = INT64_MAX;
|
||||
for (int32_t i = 0; i < pr->numOfTables; ++i) {
|
||||
STableKeyInfo* pKeyInfo = &pr->pTableList[i];
|
||||
|
||||
|
@ -351,7 +351,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
|
||||
{
|
||||
bool hasNotNullRow = true;
|
||||
int64_t minTs = INT64_MAX;
|
||||
int64_t singleTableLastTs = INT64_MAX;
|
||||
for (int32_t k = 0; k < pr->numOfCols; ++k) {
|
||||
int32_t slotId = slotIds[k];
|
||||
|
||||
|
@ -362,7 +362,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
hasRes = true;
|
||||
p->ts = pCol->ts;
|
||||
p->colVal = pCol->colVal;
|
||||
minTs = pCol->ts;
|
||||
singleTableLastTs = pCol->ts;
|
||||
|
||||
// only set value for last row query
|
||||
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST_ROW)) {
|
||||
|
@ -387,8 +387,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
|
||||
hasRes = true;
|
||||
p->ts = pColVal->ts;
|
||||
if (pColVal->ts < minTs && HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||
minTs = pColVal->ts;
|
||||
if (pColVal->ts < singleTableLastTs && HASTYPE(pr->type, CACHESCAN_RETRIEVE_LAST)) {
|
||||
singleTableLastTs = pColVal->ts;
|
||||
}
|
||||
|
||||
if (!IS_VAR_DATA_TYPE(pColVal->colVal.type)) {
|
||||
|
@ -408,12 +408,12 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
}
|
||||
|
||||
if (hasNotNullRow) {
|
||||
if (totalMinTs > minTs) {
|
||||
totalMinTs = minTs;
|
||||
if (INT64_MAX == totalLastTs || totalLastTs < singleTableLastTs) {
|
||||
totalLastTs = singleTableLastTs;
|
||||
}
|
||||
double cost = (taosGetTimestampUs() - st) / 1000.0;
|
||||
if (cost > tsCacheLazyLoadThreshold) {
|
||||
pr->lastTs = totalMinTs;
|
||||
pr->lastTs = totalLastTs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue