提交 8b82fdf0 编写于 作者: A Alex Duan

fix(query): correct calc sort page size

上级 4b4f8eac
...@@ -489,6 +489,9 @@ enum { ...@@ -489,6 +489,9 @@ enum {
#define MAX_META_MSG_IN_BATCH 1048576 #define MAX_META_MSG_IN_BATCH 1048576
#define MAX_META_BATCH_RSP_SIZE (1 * 1048576 * 1024) #define MAX_META_BATCH_RSP_SIZE (1 * 1048576 * 1024)
// sort page size by default
#define DEFAULT_PAGESIZE 4096
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
...@@ -163,9 +163,10 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle); ...@@ -163,9 +163,10 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle);
/** /**
* get proper sort buffer pages according to the row size * get proper sort buffer pages according to the row size
* @param rowSize * @param rowSize
* @param numOfCols columns count that be put into page
* @return * @return
*/ */
int32_t getProperSortPageSize(size_t rowSize); int32_t getProperSortPageSize(size_t rowSize, uint32_t numOfCols);
#ifdef __cplusplus #ifdef __cplusplus
} }
......
...@@ -4822,7 +4822,8 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN ...@@ -4822,7 +4822,8 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
initLimitInfo(pTableScanNode->scan.node.pLimit, pTableScanNode->scan.node.pSlimit, &pInfo->limitInfo); initLimitInfo(pTableScanNode->scan.node.pLimit, pTableScanNode->scan.node.pSlimit, &pInfo->limitInfo);
int32_t rowSize = pInfo->pResBlock->info.rowSize; int32_t rowSize = pInfo->pResBlock->info.rowSize;
pInfo->bufPageSize = getProperSortPageSize(rowSize); uint32_t numOfCols = taosArrayGetSize(pInfo->pResBlock->pDataBlock);
pInfo->bufPageSize = getProperSortPageSize(rowSize, numOfCols);
setOperatorInfo(pOperator, "TableMergeScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, false, OP_NOT_OPENED, setOperatorInfo(pOperator, "TableMergeScanOperator", QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN, false, OP_NOT_OPENED,
pInfo, pTaskInfo); pInfo, pTaskInfo);
......
...@@ -760,7 +760,8 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size ...@@ -760,7 +760,8 @@ SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** downStreams, size
pInfo->groupSort = pMergePhyNode->groupSort; pInfo->groupSort = pMergePhyNode->groupSort;
pInfo->pSortInfo = createSortInfo(pMergePhyNode->pMergeKeys); pInfo->pSortInfo = createSortInfo(pMergePhyNode->pMergeKeys);
pInfo->pInputBlock = pInputBlock; pInfo->pInputBlock = pInputBlock;
pInfo->bufPageSize = getProperSortPageSize(rowSize); size_t numOfCols = taosArrayGetSize(pInfo->binfo.pRes->pDataBlock);
pInfo->bufPageSize = getProperSortPageSize(rowSize, numOfCols);
pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result. pInfo->sortBufSize = pInfo->bufPageSize * (numStreams + 1); // one additional is reserved for merged result.
setOperatorInfo(pOperator, "MultiwayMergeOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE, false, OP_NOT_OPENED, pInfo, pTaskInfo); setOperatorInfo(pOperator, "MultiwayMergeOperator", QUERY_NODE_PHYSICAL_PLAN_MERGE, false, OP_NOT_OPENED, pInfo, pTaskInfo);
......
...@@ -584,15 +584,11 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { ...@@ -584,15 +584,11 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
return 0; return 0;
} }
// TODO consider the page meta size // get sort page size
int32_t getProperSortPageSize(size_t rowSize) { int32_t getProperSortPageSize(size_t rowSize, uint32_t numOfCols) {
uint32_t defaultPageSize = 4096; uint32_t pgSize = rowSize * 4 + blockDataGetSerialMetaSize(numOfCols);
if (pgSize < DEFAULT_PAGESIZE) {
uint32_t pgSize = 0; return DEFAULT_PAGESIZE;
if (rowSize * 4 > defaultPageSize) {
pgSize = rowSize * 4;
} else {
pgSize = defaultPageSize;
} }
return pgSize; return pgSize;
...@@ -612,7 +608,8 @@ static int32_t createInitialSources(SSortHandle* pHandle) { ...@@ -612,7 +608,8 @@ static int32_t createInitialSources(SSortHandle* pHandle) {
} }
if (pHandle->pDataBlock == NULL) { if (pHandle->pDataBlock == NULL) {
pHandle->pageSize = getProperSortPageSize(blockDataGetRowSize(pBlock)); uint32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
pHandle->pageSize = getProperSortPageSize(blockDataGetRowSize(pBlock), numOfCols);
// todo, number of pages are set according to the total available sort buffer // todo, number of pages are set according to the total available sort buffer
pHandle->numOfPages = 1024; pHandle->numOfPages = 1024;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册