enhance: table san type and disable partition tags optimize for tag scan
This commit is contained in:
parent
d7c55cf8fc
commit
e93ed3b556
|
@ -117,7 +117,7 @@ void* tableListDestroy(STableListInfo* pTableListInfo);
|
||||||
void tableListClear(STableListInfo* pTableListInfo);
|
void tableListClear(STableListInfo* pTableListInfo);
|
||||||
int32_t tableListGetOutputGroups(const STableListInfo* pTableList);
|
int32_t tableListGetOutputGroups(const STableListInfo* pTableList);
|
||||||
bool oneTableForEachGroup(const STableListInfo* pTableList);
|
bool oneTableForEachGroup(const STableListInfo* pTableList);
|
||||||
uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid);
|
uint64_t tableListGetTableGroupId(const STableListInfo* pTableList, uint64_t tableUid);
|
||||||
int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t gid);
|
int32_t tableListAddTableInfo(STableListInfo* pTableList, uint64_t uid, uint64_t gid);
|
||||||
int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalIndex, STableKeyInfo** pKeyInfo,
|
int32_t tableListGetGroupList(const STableListInfo* pTableList, int32_t ordinalIndex, STableKeyInfo** pKeyInfo,
|
||||||
int32_t* num);
|
int32_t* num);
|
||||||
|
|
|
@ -218,7 +218,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pRes->info.id.groupId = getTableGroupId(pTableList, pRes->info.id.uid);
|
pRes->info.id.groupId = tableListGetTableGroupId(pTableList, pRes->info.id.uid);
|
||||||
pInfo->indexOfBufferedRes += 1;
|
pInfo->indexOfBufferedRes += 1;
|
||||||
return pRes;
|
return pRes;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1930,7 +1930,7 @@ void tableListGetSourceTableInfo(const STableListInfo* pTableList, uint64_t* psu
|
||||||
*type = pTableList->idInfo.tableType;
|
*type = pTableList->idInfo.tableType;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) {
|
uint64_t tableListGetTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) {
|
||||||
int32_t* slot = taosHashGet(pTableList->map, &tableUid, sizeof(tableUid));
|
int32_t* slot = taosHashGet(pTableList->map, &tableUid, sizeof(tableUid));
|
||||||
ASSERT(pTableList->map != NULL && slot != NULL);
|
ASSERT(pTableList->map != NULL && slot != NULL);
|
||||||
|
|
||||||
|
|
|
@ -693,7 +693,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pBlock->info.id.uid) {
|
if (pBlock->info.id.uid) {
|
||||||
pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
pBlock->info.id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
|
@ -1088,7 +1088,7 @@ static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbU
|
||||||
if (hasNext) {
|
if (hasNext) {
|
||||||
/*SSDataBlock* p = */ pAPI->tsdReader.tsdReaderRetrieveDataBlock(pReader, NULL);
|
/*SSDataBlock* p = */ pAPI->tsdReader.tsdReaderRetrieveDataBlock(pReader, NULL);
|
||||||
doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows);
|
doSetTagColumnData(&pTableScanInfo->base, pBlock, pTaskInfo, pBlock->info.rows);
|
||||||
pBlock->info.id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
pBlock->info.id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
pAPI->tsdReader.tsdReaderClose(pReader);
|
pAPI->tsdReader.tsdReaderClose(pReader);
|
||||||
|
@ -1110,7 +1110,7 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts,
|
||||||
|
|
||||||
static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
||||||
STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info;
|
STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info;
|
||||||
return getTableGroupId(pTableScanInfo->base.pTableListInfo, uid);
|
return tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
||||||
|
@ -1651,7 +1651,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
pBlockInfo->version = pBlock->info.version;
|
pBlockInfo->version = pBlock->info.version;
|
||||||
|
|
||||||
STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info;
|
STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info;
|
||||||
pBlockInfo->id.groupId = getTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
pBlockInfo->id.groupId = tableListGetTableGroupId(pTableScanInfo->base.pTableListInfo, pBlock->info.id.uid);
|
||||||
|
|
||||||
// todo extract method
|
// todo extract method
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
||||||
|
@ -2795,11 +2795,6 @@ static void tagScanFilterByTagCond(SArray* aUidTags, SNode* pTagCond, SArray* aF
|
||||||
static void tagScanFillOneCellWithTag(const STUidTagInfo* pUidTagInfo, SExprInfo* pExprInfo, SColumnInfoData* pColInfo, int rowIndex, const SStorageAPI* pAPI, void* pVnode) {
|
static void tagScanFillOneCellWithTag(const STUidTagInfo* pUidTagInfo, SExprInfo* pExprInfo, SColumnInfoData* pColInfo, int rowIndex, const SStorageAPI* pAPI, void* pVnode) {
|
||||||
if (fmIsScanPseudoColumnFunc(pExprInfo->pExpr->_function.functionId)) { // tbname
|
if (fmIsScanPseudoColumnFunc(pExprInfo->pExpr->_function.functionId)) { // tbname
|
||||||
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
char str[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
|
||||||
// if (pUidTagInfo->name != NULL) {
|
|
||||||
// STR_TO_VARSTR(str, pUidTagInfo->name);
|
|
||||||
// } else { // name is not retrieved during filter
|
|
||||||
// pAPI->metaFn.getTableNameByUid(pVnode, pUidTagInfo->uid, str);
|
|
||||||
// }
|
|
||||||
STR_TO_VARSTR(str, "ctbidx");
|
STR_TO_VARSTR(str, "ctbidx");
|
||||||
|
|
||||||
colDataSetVal(pColInfo, rowIndex, str, false);
|
colDataSetVal(pColInfo, rowIndex, str, false);
|
||||||
|
@ -3106,7 +3101,7 @@ static SSDataBlock* getBlockForTableMergeScan(void* param) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pBlock->info.id.groupId = getTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid);
|
pBlock->info.id.groupId = tableListGetTableGroupId(pInfo->base.pTableListInfo, pBlock->info.id.uid);
|
||||||
|
|
||||||
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
pOperator->resultInfo.totalRows += pBlock->info.rows;
|
||||||
pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
pInfo->base.readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
|
|
@ -253,7 +253,7 @@ static EScanType getScanType(SLogicPlanContext* pCxt, SNodeList* pScanPseudoCols
|
||||||
return SCAN_TYPE_SYSTEM_TABLE;
|
return SCAN_TYPE_SYSTEM_TABLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagScan) {
|
if (tagScan && 0 == LIST_LENGTH(pScanCols) && 0 != LIST_LENGTH(pScanPseudoCols)) {
|
||||||
return SCAN_TYPE_TAG;
|
return SCAN_TYPE_TAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,17 +366,16 @@ static bool tagScanNodeHasTbname(SNode* pKeys) {
|
||||||
return hasTbname;
|
return hasTbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t setTagScanExecutionMode(SScanLogicNode* pScan) {
|
static int32_t tagScanSetExecutionMode(SScanLogicNode* pScan) {
|
||||||
//TODO: set pScan->onlyMetaCtbIdx
|
pScan->onlyMetaCtbIdx = false;
|
||||||
bool bOnlyMetaCtbIdx = false;
|
|
||||||
|
|
||||||
if (tagScanNodeListHasTbname(pScan->pScanPseudoCols)) {
|
if (tagScanNodeListHasTbname(pScan->pScanPseudoCols)) {
|
||||||
bOnlyMetaCtbIdx = false;
|
pScan->onlyMetaCtbIdx = false;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pScan->node.pConditions == NULL) {
|
if (pScan->node.pConditions == NULL) {
|
||||||
bOnlyMetaCtbIdx = true;
|
pScan->onlyMetaCtbIdx = true;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -385,9 +384,9 @@ static int32_t setTagScanExecutionMode(SScanLogicNode* pScan) {
|
||||||
SNode* pTagIndexCond = NULL;
|
SNode* pTagIndexCond = NULL;
|
||||||
filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL);
|
filterPartitionCond(&pCond, NULL, &pTagIndexCond, &pTagCond, NULL);
|
||||||
if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) {
|
if (pTagIndexCond || tagScanNodeHasTbname(pTagCond)) {
|
||||||
bOnlyMetaCtbIdx = false;
|
pScan->onlyMetaCtbIdx = false;
|
||||||
} else {
|
} else {
|
||||||
bOnlyMetaCtbIdx = true;
|
pScan->onlyMetaCtbIdx = true;
|
||||||
}
|
}
|
||||||
nodesDestroyNode(pCond);
|
nodesDestroyNode(pCond);
|
||||||
nodesDestroyNode(pTagIndexCond);
|
nodesDestroyNode(pTagIndexCond);
|
||||||
|
@ -462,8 +461,8 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
|
||||||
code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pScan->node.pTargets);
|
code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pScan->node.pTargets);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pSelect->tagScan) {
|
if (pScan->scanType == SCAN_TYPE_TAG) {
|
||||||
code = setTagScanExecutionMode(pScan);
|
code = tagScanSetExecutionMode(pScan);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
|
|
@ -1563,7 +1563,8 @@ static bool planOptNodeListHasTbname(SNodeList* pKeys) {
|
||||||
|
|
||||||
static bool partTagsIsOptimizableNode(SLogicNode* pNode) {
|
static bool partTagsIsOptimizableNode(SLogicNode* pNode) {
|
||||||
bool ret = 1 == LIST_LENGTH(pNode->pChildren) &&
|
bool ret = 1 == LIST_LENGTH(pNode->pChildren) &&
|
||||||
QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0));
|
QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(nodesListGetNode(pNode->pChildren, 0) &&
|
||||||
|
SCAN_TYPE_TAG != ((SScanLogicNode*)(nodesListGetNode(pNode->pChildren, 0)))->scanType);
|
||||||
if (!ret) return ret;
|
if (!ret) return ret;
|
||||||
switch (nodeType(pNode)) {
|
switch (nodeType(pNode)) {
|
||||||
case QUERY_NODE_LOGIC_PLAN_PARTITION: {
|
case QUERY_NODE_LOGIC_PLAN_PARTITION: {
|
||||||
|
|
Loading…
Reference in New Issue