feat: super table order by primary key optimization
This commit is contained in:
parent
fc0780c35a
commit
9053645ab7
|
@ -434,8 +434,8 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
|||
}
|
||||
|
||||
struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol, int32_t primaryTsSlotId,
|
||||
const char* id) {
|
||||
SInterval* pInterval, int32_t fillType, struct SFillColInfo* pCol,
|
||||
int32_t primaryTsSlotId, const char* id) {
|
||||
if (fillType == TSDB_FILL_NONE) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -581,7 +581,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma
|
|||
|
||||
int64_t numOfRes = -1;
|
||||
if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set.
|
||||
TSKEY lastKey = tsList[pFillInfo->numOfRows - 1];
|
||||
TSKEY lastKey = (TSDB_ORDER_ASC == pFillInfo->order ? tsList[pFillInfo->numOfRows - 1] : tsList[0]);
|
||||
numOfRes = taosTimeCountInterval(lastKey, pFillInfo->currentKey, pFillInfo->interval.sliding,
|
||||
pFillInfo->interval.slidingUnit, pFillInfo->interval.precision);
|
||||
numOfRes += 1;
|
||||
|
@ -626,8 +626,8 @@ int64_t taosFillResultDataBlock(SFillInfo* pFillInfo, SSDataBlock* p, int32_t ca
|
|||
}
|
||||
|
||||
qDebug("fill:%p, generated fill result, src block:%d, index:%d, brange:%" PRId64 "-%" PRId64 ", currentKey:%" PRId64
|
||||
", current : % d, total : % d, %s", pFillInfo,
|
||||
pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
|
||||
", current : % d, total : % d, %s",
|
||||
pFillInfo, pFillInfo->numOfRows, pFillInfo->index, pFillInfo->start, pFillInfo->end, pFillInfo->currentKey,
|
||||
pFillInfo->numOfCurrent, pFillInfo->numOfTotal, pFillInfo->id);
|
||||
|
||||
return numOfRes;
|
||||
|
|
|
@ -1122,7 +1122,7 @@ static int32_t sortPriKeyOptApply(SOptimizeContext* pCxt, SLogicSubplan* pLogicS
|
|||
SNode* pScanNode = NULL;
|
||||
FOREACH(pScanNode, pScanNodes) {
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pScanNode;
|
||||
if (ORDER_DESC == order && pScan->scanSeq[0] > 0) {
|
||||
if ((ORDER_DESC == order && pScan->scanSeq[0] > 0) || (ORDER_ASC == order && pScan->scanSeq[1] > 0)) {
|
||||
TSWAP(pScan->scanSeq[0], pScan->scanSeq[1]);
|
||||
}
|
||||
if (TSDB_SUPER_TABLE == pScan->tableType) {
|
||||
|
|
|
@ -469,7 +469,7 @@ if $data24 != 9.000000000 then
|
|||
endi
|
||||
|
||||
### supertable aggregation + where + interval + limit offset
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit 5 offset 1
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) order by _wstart limit 5 offset 1
|
||||
if $rows != 5 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -487,7 +487,7 @@ if $data41 != 5 then
|
|||
endi
|
||||
$offset = $rowNum / 2
|
||||
$offset = $offset + 1
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) limit $offset offset $offset
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9) from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 interval(5m) order by _wstart limit $offset offset $offset
|
||||
$val = $rowNum - $offset
|
||||
if $rows != $val then
|
||||
return -1
|
||||
|
@ -507,7 +507,7 @@ endi
|
|||
|
||||
### supertable aggregation + where + interval + group by order by tag + limit offset
|
||||
## TBASE-345
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 0
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc, _wstart limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -531,7 +531,7 @@ if $data29 != 3 then
|
|||
endi
|
||||
|
||||
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 1
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc, _wstart limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -542,7 +542,7 @@ if $data09 != 4 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 1 offset 0
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 5 and c1 > 0 and c2 < 9 and c3 > 1 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc, _wstart limit 1 offset 0
|
||||
if $rows != 1 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -553,7 +553,7 @@ if $data09 != 4 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc limit 3 offset 0
|
||||
sql select _wstart, max(c1), min(c2), avg(c3), sum(c5), spread(c6), first(c7), last(c8), first(c9), t1 from $stb where ts >= $ts0 and ts <= $tsu and t1 > 1 and t1 < 8 and c1 > 0 and c2 < 9 and c3 > 4 and c4 < 7 and c5 > 4 partition by t1 interval(5m) order by t1 desc, _wstart limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
|
|
@ -728,7 +728,7 @@ sql select last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb w
|
|||
if $rows != 0 then
|
||||
return -1
|
||||
endi
|
||||
sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) limit 3 offset 1
|
||||
sql select _wstart, last(c1), last(c2), last(c3), last(c4), last(c5), last(c6) from $tb where ts >= $ts0 and ts <= $tsu interval(30m) order by _wstart limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -742,7 +742,7 @@ if $data23 != 9.00000 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 0
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) order by _wstart limit 3 offset 0
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
@ -777,7 +777,7 @@ if $data29 != nchar8 then
|
|||
return -1
|
||||
endi
|
||||
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) limit 3 offset 1
|
||||
sql select _wstart, first(ts), first(c1), last(c2), first(c3), last(c4), first(c5), last(c6), first(c8), last(c9) from $tb where ts >= $ts0 and ts <= $tsu and c1 > 0 interval(30m) order by _wstart limit 3 offset 1
|
||||
if $rows != 3 then
|
||||
return -1
|
||||
endi
|
||||
|
|
Loading…
Reference in New Issue