[td-225] opt query perf
This commit is contained in:
parent
43b7996c90
commit
1f9ebc0d48
|
@ -3291,16 +3291,17 @@ void destroyTableQueryInfo(STableQueryInfo *pTableQueryInfo, int32_t numOfCols)
|
|||
free(pTableQueryInfo);
|
||||
}
|
||||
|
||||
void setCurrentQueryTable(SQueryRuntimeEnv *pRuntimeEnv, STableQueryInfo *pTableQueryInfo) {
|
||||
SQuery *pQuery = pRuntimeEnv->pQuery;
|
||||
pQuery->current = pTableQueryInfo;
|
||||
|
||||
assert(((pTableQueryInfo->lastKey >= pTableQueryInfo->win.skey) && QUERY_IS_ASC_QUERY(pQuery)) ||
|
||||
((pTableQueryInfo->lastKey <= pTableQueryInfo->win.skey) && !QUERY_IS_ASC_QUERY(pQuery)));
|
||||
}
|
||||
#define SET_CURRENT_QUERY_TABLE_INFO(_runtime, _tableInfo) \
|
||||
do { \
|
||||
SQuery *_query = (_runtime)->pQuery; \
|
||||
_query->current = _tableInfo; \
|
||||
assert((((_tableInfo)->lastKey >= (_tableInfo)->win.skey) && QUERY_IS_ASC_QUERY(_query)) || \
|
||||
(((_tableInfo)->lastKey <= (_tableInfo)->win.skey) && !QUERY_IS_ASC_QUERY(_query))); \
|
||||
} while (0)
|
||||
|
||||
/**
|
||||
* set output buffer for different group
|
||||
* TODO opt performance if current group is identical to previous group
|
||||
* @param pRuntimeEnv
|
||||
* @param pDataBlockInfo
|
||||
*/
|
||||
|
@ -4165,32 +4166,9 @@ static int64_t scanMultiTableDataBlocks(SQInfo *pQInfo) {
|
|||
if(pTableQueryInfo == NULL) {
|
||||
break;
|
||||
}
|
||||
// todo opt performance using hash table
|
||||
|
||||
// size_t numOfGroup = GET_NUM_OF_TABLEGROUP(pQInfo);
|
||||
// for (int32_t i = 0; i < numOfGroup; ++i) {
|
||||
// SArray *group = GET_TABLEGROUP(pQInfo, i);
|
||||
//
|
||||
// size_t num = taosArrayGetSize(group);
|
||||
// for (int32_t j = 0; j < num; ++j) {
|
||||
// STableQueryInfo *p = taosArrayGetP(group, j);
|
||||
//
|
||||
// STableId id = tsdbGetTableId(p->pTable);
|
||||
// if (id.tid == blockInfo.tid) {
|
||||
// assert(id.uid == blockInfo.uid);
|
||||
// pTableQueryInfo = p;
|
||||
//
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if (pTableQueryInfo != NULL) {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
assert(*pTableQueryInfo != NULL);
|
||||
setCurrentQueryTable(pRuntimeEnv, *pTableQueryInfo);
|
||||
SET_CURRENT_QUERY_TABLE_INFO(pRuntimeEnv, *pTableQueryInfo);
|
||||
|
||||
SDataStatis *pStatis = NULL;
|
||||
SArray *pDataBlock = loadDataBlockOnDemand(pRuntimeEnv, pQueryHandle, &blockInfo, &pStatis);
|
||||
|
|
|
@ -209,8 +209,7 @@ int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
return FILL_IS_ASC_FILL(pFillInfo) ? (pFillInfo->numOfRows - pFillInfo->rowIdx)
|
||||
: pFillInfo->rowIdx + 1;
|
||||
return FILL_IS_ASC_FILL(pFillInfo) ? (pFillInfo->numOfRows - pFillInfo->rowIdx) : pFillInfo->rowIdx + 1;
|
||||
}
|
||||
|
||||
// todo: refactor
|
||||
|
|
|
@ -542,17 +542,12 @@ static int32_t getFileCompInfo(STsdbQueryHandle* pQueryHandle, int32_t* numOfBlo
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static SDataBlockInfo getTrueDataBlockInfo(STableCheckInfo* pCheckInfo, SCompBlock* pBlock) {
|
||||
SDataBlockInfo info = {
|
||||
.window = {.skey = pBlock->keyFirst, .ekey = pBlock->keyLast},
|
||||
.numOfCols = pBlock->numOfCols,
|
||||
.rows = pBlock->numOfRows,
|
||||
.tid = pCheckInfo->tableId.tid,
|
||||
.uid = pCheckInfo->tableId.uid,
|
||||
};
|
||||
|
||||
return info;
|
||||
}
|
||||
#define GET_FILE_DATA_BLOCK_INFO(_checkInfo, _block) \
|
||||
((SDataBlockInfo){.window = {.skey = (_block)->keyFirst, .ekey = (_block)->keyLast}, \
|
||||
.numOfCols = (_block)->numOfCols, \
|
||||
.rows = (_block)->numOfRows, \
|
||||
.tid = (_checkInfo)->tableId.tid, \
|
||||
.uid = (_checkInfo)->tableId.uid})
|
||||
|
||||
static SArray* getColumnIdList(STsdbQueryHandle* pQueryHandle) {
|
||||
size_t numOfCols = QH_GET_NUM_OF_COLS(pQueryHandle);
|
||||
|
@ -626,7 +621,7 @@ static bool doLoadFileDataBlock(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlo
|
|||
|
||||
static void handleDataMergeIfNeeded(STsdbQueryHandle* pQueryHandle, SCompBlock* pBlock, STableCheckInfo* pCheckInfo){
|
||||
SQueryFilePos* cur = &pQueryHandle->cur;
|
||||
SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlock);
|
||||
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
||||
|
||||
/*bool hasData = */ initTableMemIterator(pQueryHandle, pCheckInfo);
|
||||
SDataRow row = getSDataRowInTableMem(pCheckInfo);
|
||||
|
@ -946,7 +941,7 @@ static void copyOneRowFromMem(STsdbQueryHandle* pQueryHandle, int32_t capacity,
|
|||
static void doMergeTwoLevelData(STsdbQueryHandle* pQueryHandle, STableCheckInfo* pCheckInfo, SCompBlock* pBlock,
|
||||
SArray* sa) {
|
||||
SQueryFilePos* cur = &pQueryHandle->cur;
|
||||
SDataBlockInfo blockInfo = getTrueDataBlockInfo(pCheckInfo, pBlock);
|
||||
SDataBlockInfo blockInfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlock);
|
||||
|
||||
initTableMemIterator(pQueryHandle, pCheckInfo);
|
||||
SDataCols* pCols = pQueryHandle->rhelper.pDataCols[0];
|
||||
|
@ -1322,8 +1317,8 @@ static int32_t createDataBlocksInfo(STsdbQueryHandle* pQueryHandle, int32_t numO
|
|||
|
||||
assert(cnt <= numOfBlocks && numOfQualTables <= numOfTables); // the pTableQueryInfo[j]->numOfBlocks may be 0
|
||||
sup.numOfTables = numOfQualTables;
|
||||
SLoserTreeInfo* pTree = NULL;
|
||||
|
||||
SLoserTreeInfo* pTree = NULL;
|
||||
uint8_t ret = tLoserTreeCreate(&pTree, sup.numOfTables, &sup, dataBlockOrderCompar);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
cleanBlockOrderSupporter(&sup, numOfTables);
|
||||
|
@ -1844,7 +1839,7 @@ SArray* tsdbRetrieveDataBlock(TsdbQueryHandleT* pQueryHandle, SArray* pIdList) {
|
|||
if (pHandle->cur.mixBlock) {
|
||||
return pHandle->pColumns;
|
||||
} else {
|
||||
SDataBlockInfo binfo = getTrueDataBlockInfo(pCheckInfo, pBlockInfo->compBlock);
|
||||
SDataBlockInfo binfo = GET_FILE_DATA_BLOCK_INFO(pCheckInfo, pBlockInfo->compBlock);
|
||||
assert(pHandle->realNumOfRows <= binfo.rows);
|
||||
|
||||
// data block has been loaded, todo extract method
|
||||
|
|
|
@ -137,7 +137,6 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SReadMsg *pReadMsg) {
|
|||
}
|
||||
|
||||
if (pQInfo != NULL) {
|
||||
vDebug("vgId:%d, QInfo:%p, do qTableQuery", pVnode->vgId, pQInfo);
|
||||
qTableQuery(pQInfo, vnodeRelease, pVnode); // do execute query
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue