Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8cf3339b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8cf3339b
编写于
10月 26, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh(query): enable the limit clause to be push down to the table scan operator.
上级
4b15cd5e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
29 deletion
+48
-29
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+15
-17
source/libs/executor/src/projectoperator.c
source/libs/executor/src/projectoperator.c
+0
-2
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+32
-9
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+1
-1
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
8cf3339b
...
...
@@ -316,27 +316,25 @@ typedef struct {
}
SAggOptrPushDownInfo
;
typedef
struct
STableScanInfo
{
STsdbReader
*
dataReader
;
SReadHandle
readHandle
;
STsdbReader
*
dataReader
;
SReadHandle
readHandle
;
SLimitInfo
limitInfo
;
SFileBlockLoadRecorder
readRecorder
;
SScanInfo
scanInfo
;
int32_t
scanTimes
;
SNode
*
pFilterNode
;
// filter info, which is push down by optimizer
SSDataBlock
*
pResBlock
;
SColMatchInfo
matchInfo
;
SExprSupp
pseudoSup
;
SQueryTableDataCond
cond
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
SSampleExecInfo
sample
;
// sample execution info
int32_t
currentGroupId
;
int32_t
currentTable
;
int8_t
scanMode
;
int8_t
noTable
;
SAggOptrPushDownInfo
pdInfo
;
int8_t
assignBlockUid
;
SSDataBlock
*
pResBlock
;
SColMatchInfo
matchInfo
;
SExprSupp
pseudoSup
;
SQueryTableDataCond
cond
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
SSampleExecInfo
sample
;
// sample execution info
int32_t
currentGroupId
;
int32_t
currentTable
;
int8_t
scanMode
;
SAggOptrPushDownInfo
pdInfo
;
int8_t
assignBlockUid
;
}
STableScanInfo
;
typedef
struct
STableMergeScanInfo
{
...
...
source/libs/executor/src/projectoperator.c
浏览文件 @
8cf3339b
...
...
@@ -210,8 +210,6 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
pOperator
->
status
=
OP_OPENED
;
}
qDebug
(
"enter project"
);
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
pTaskInfo
->
execModel
==
OPTR_EXEC_MODEL_QUEUE
)
{
pOperator
->
status
=
OP_OPENED
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
8cf3339b
...
...
@@ -364,6 +364,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
pCost
->
totalBlocks
+=
1
;
pCost
->
totalRows
+=
pBlock
->
info
.
rows
;
bool
loadSMA
=
false
;
*
status
=
pInfo
->
dataBlockLoadFlag
;
...
...
@@ -379,6 +380,7 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
qDebug
(
"%s data block filter out, brange:%"
PRId64
"-%"
PRId64
", rows:%d"
,
GET_TASKID
(
pTaskInfo
),
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
pBlockInfo
->
rows
);
pCost
->
filterOutBlocks
+=
1
;
pCost
->
totalRows
+=
pBlock
->
info
.
rows
;
return
TSDB_CODE_SUCCESS
;
}
else
if
(
*
status
==
FUNC_DATA_REQUIRED_NOT_LOAD
)
{
qDebug
(
"%s data block skipped, brange:%"
PRId64
"-%"
PRId64
", rows:%d"
,
GET_TASKID
(
pTaskInfo
),
...
...
@@ -447,6 +449,10 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
doSetTagColumnData
(
pTableScanInfo
,
pBlock
,
pTaskInfo
);
if
(
pTableScanInfo
->
pFilterNode
!=
NULL
)
{
// restore the previous value
pCost
->
totalRows
-=
pBlock
->
info
.
rows
;
int64_t
st
=
taosGetTimestampUs
();
doFilter
(
pTableScanInfo
->
pFilterNode
,
pBlock
,
&
pTableScanInfo
->
matchInfo
,
pOperator
->
exprSupp
.
pFilterInfo
);
...
...
@@ -460,6 +466,22 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
}
else
{
qDebug
(
"%s data block filter applied, elapsed time:%.2f ms"
,
GET_TASKID
(
pTaskInfo
),
el
);
}
pCost
->
totalRows
+=
pBlock
->
info
.
rows
;
}
pInfo
->
limitInfo
.
numOfOutputRows
=
pCost
->
totalRows
;
SLimit
*
pLimit
=
&
pInfo
->
limitInfo
.
limit
;
if
(
pLimit
->
limit
!=
-
1
&&
pLimit
->
limit
<
pInfo
->
limitInfo
.
numOfOutputRows
&&
pBlock
->
info
.
rows
>
0
)
{
// limit the output rows
int32_t
overflowRows
=
pInfo
->
limitInfo
.
numOfOutputRows
-
pLimit
->
limit
;
int32_t
keep
=
pBlock
->
info
.
rows
-
overflowRows
;
blockDataKeepFirstNRows
(
pBlock
,
keep
);
qDebug
(
"output limit %"
PRId64
" has reached, %s"
,
pLimit
->
limit
,
GET_TASKID
(
pTaskInfo
));
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
pOperator
->
status
=
OP_EXEC_DONE
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -691,10 +713,6 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
// if scan table by table
if
(
pInfo
->
scanMode
==
TABLE_SCAN__TABLE_ORDER
)
{
if
(
pInfo
->
noTable
)
{
return
NULL
;
}
int32_t
numOfTables
=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pTableList
);
while
(
1
)
{
...
...
@@ -727,7 +745,6 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
tsdbReaderClose
(
pInfo
->
dataReader
);
int32_t
code
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
tableList
,
(
STsdbReader
**
)
&
pInfo
->
dataReader
,
...
...
@@ -749,9 +766,6 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
return
NULL
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
// tsdbSetTableList(pInfo->dataReader, tableList);
tsdbReaderReset
(
pInfo
->
dataReader
,
&
pInfo
->
cond
);
pInfo
->
scanTimes
=
0
;
...
...
@@ -798,9 +812,15 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
}
SDataBlockDescNode
*
pDescNode
=
pTableScanNode
->
scan
.
node
.
pOutputDataBlockDesc
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
int32_t
code
=
extractColMatchInfo
(
pTableScanNode
->
scan
.
pScanCols
,
pDescNode
,
&
numOfCols
,
COL_MATCH_FROM_COL_ID
,
&
pInfo
->
matchInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
initLimitInfo
(
pTableScanNode
->
scan
.
node
.
pLimit
,
pTableScanNode
->
scan
.
node
.
pSlimit
,
&
pInfo
->
limitInfo
);
code
=
initQueryTableDataCond
(
&
pInfo
->
cond
,
pTableScanNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -825,6 +845,9 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
if
(
pInfo
->
pFilterNode
!=
NULL
)
{
code
=
filterInitFromNode
((
SNode
*
)
pInfo
->
pFilterNode
,
&
pOperator
->
exprSupp
.
pFilterInfo
,
0
);
if
(
code
!=
TSDB_CODE_OUT_OF_MEMORY
)
{
goto
_error
;
}
}
pInfo
->
scanFlag
=
MAIN_SCAN
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
8cf3339b
...
...
@@ -2498,7 +2498,7 @@ static const SOptimizeRule optimizeRuleSet[] = {
{.
pName
=
"RewriteUnique"
,
.
optimizeFunc
=
rewriteUniqueOptimize
},
{.
pName
=
"LastRowScan"
,
.
optimizeFunc
=
lastRowScanOptimize
},
{.
pName
=
"TagScan"
,
.
optimizeFunc
=
tagScanOptimize
},
//
{.pName = "PushDownLimit", .optimizeFunc = pushDownLimitOptimize}
{.
pName
=
"PushDownLimit"
,
.
optimizeFunc
=
pushDownLimitOptimize
}
};
// clang-format on
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录