Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c079b774
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c079b774
编写于
12月 16, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-2176]<enhance>: improve the first/last query performance against super table.
上级
9204eebf
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
33 deletion
+27
-33
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+16
-19
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+11
-14
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
c079b774
...
...
@@ -708,15 +708,14 @@ static int32_t firstDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY en
return
BLK_DATA_ALL_NEEDED
;
}
return
BLK_DATA_ALL_NEEDED
;
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
// is invalid
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
// if (pInfo->hasResult != DATA_SET_FLAG) {
// return BLK_DATA_ALL_NEEDED;
// } else { // data in current block is not earlier than current result
// return (pInfo->ts <= start) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
// }
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->aOutputBuf is
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)
(
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
return
BLK_DATA_ALL_NEEDED
;
}
else
{
// data in current block is not earlier than current result
return
(
pInfo
->
ts
<=
start
)
?
BLK_DATA_NO_NEEDED
:
BLK_DATA_ALL_NEEDED
;
}
}
static
int32_t
lastDistFuncRequired
(
SQLFunctionCtx
*
pCtx
,
TSKEY
start
,
TSKEY
end
,
int32_t
colId
)
{
...
...
@@ -729,16 +728,14 @@ static int32_t lastDistFuncRequired(SQLFunctionCtx *pCtx, TSKEY start, TSKEY end
return
BLK_DATA_ALL_NEEDED
;
}
return
BLK_DATA_ALL_NEEDED
;
// TODO pCtx->aOutputBuf is the previous windowRes output buffer, not current unloaded block. so the following filter
// is invalid
// SFirstLastInfo *pInfo = (SFirstLastInfo*) (pCtx->aOutputBuf + pCtx->inputBytes);
// if (pInfo->hasResult != DATA_SET_FLAG) {
// return BLK_DATA_ALL_NEEDED;
// } else {
// return (pInfo->ts > end) ? BLK_DATA_NO_NEEDED : BLK_DATA_ALL_NEEDED;
// }
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->aOutputBuf is
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)
(
pCtx
->
aOutputBuf
+
pCtx
->
inputBytes
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
return
BLK_DATA_ALL_NEEDED
;
}
else
{
return
(
pInfo
->
ts
>
end
)
?
BLK_DATA_NO_NEEDED
:
BLK_DATA_ALL_NEEDED
;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////
...
...
src/query/src/qExecutor.c
浏览文件 @
c079b774
...
...
@@ -624,9 +624,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SResultRow
SResultRow
*
pResultRow
=
doPrepareResultRowFromKey
(
pRuntimeEnv
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
uid
);
if
(
pResultRow
==
NULL
)
{
*
newWind
=
false
;
// no master scan, no result generated means error occurs
return
masterscan
?
-
1
:
0
;
return
masterscan
?
-
1
:
0
;
// no master scan, no result generated means error occurs
}
*
newWind
=
true
;
...
...
@@ -2617,10 +2615,11 @@ static bool overlapWithTimeWindow(SQuery* pQuery, SDataBlockInfo* pBlockInfo) {
}
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pWindowResInfo
,
void
*
pQueryHandle
,
SDataBlockInfo
*
pBlockInfo
,
SDataStatis
**
pStatis
,
SArray
**
pDataBlock
,
uint32_t
*
status
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
*
status
=
BLK_DATA_NO_NEEDED
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
SQueryCostInfo
*
pCost
=
&
pRuntimeEnv
->
summary
;
if
(
pQuery
->
numOfFilterCols
>
0
||
pRuntimeEnv
->
pTsBuf
>
0
)
{
*
status
=
BLK_DATA_ALL_NEEDED
;
}
else
{
// check if this data block is required to load
...
...
@@ -2641,7 +2640,6 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo * pW
bool
masterScan
=
IS_MASTER_SCAN
(
pRuntimeEnv
);
TSKEY
k
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
pBlockInfo
->
window
.
skey
:
pBlockInfo
->
window
.
ekey
;
STimeWindow
win
=
getActiveTimeWindow
(
pWindowResInfo
,
k
,
pQuery
);
if
(
setWindowOutputBufByKey
(
pRuntimeEnv
,
pWindowResInfo
,
pBlockInfo
,
&
win
,
masterScan
,
&
hasTimeWindow
,
&
pResult
)
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2665,35 +2663,34 @@ int32_t loadDataBlockOnDemand(SQueryRuntimeEnv *pRuntimeEnv, SResultRowInfo * pW
if
((
*
status
)
==
BLK_DATA_NO_NEEDED
)
{
qDebug
(
"QInfo:%p data block discard, brange:%"
PRId64
"-%"
PRId64
", rows:%d"
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
pBlockInfo
->
rows
);
p
RuntimeEnv
->
summary
.
discardBlocks
+=
1
;
p
Cost
->
discardBlocks
+=
1
;
}
else
if
((
*
status
)
==
BLK_DATA_STATIS_NEEDED
)
{
// this function never returns error?
tsdbRetrieveDataBlockStatisInfo
(
pQueryHandle
,
pStatis
);
pRuntimeEnv
->
summary
.
loadBlockStatis
+=
1
;
pCost
->
loadBlockStatis
+=
1
;
if
(
*
pStatis
==
NULL
)
{
// data block statistics does not exist, load data block
*
pDataBlock
=
tsdbRetrieveDataBlock
(
pQueryHandle
,
NULL
);
p
RuntimeEnv
->
summary
.
totalCheckedRows
+=
pBlockInfo
->
rows
;
p
Cost
->
totalCheckedRows
+=
pBlockInfo
->
rows
;
}
}
else
{
assert
((
*
status
)
==
BLK_DATA_ALL_NEEDED
);
// load the data block statistics to perform further filter
p
RuntimeEnv
->
summary
.
loadBlockStatis
+=
1
;
p
Cost
->
loadBlockStatis
+=
1
;
tsdbRetrieveDataBlockStatisInfo
(
pQueryHandle
,
pStatis
);
if
(
!
needToLoadDataBlock
(
pRuntimeEnv
,
*
pStatis
,
pRuntimeEnv
->
pCtx
,
pBlockInfo
->
rows
))
{
// current block has been discard due to filter applied
p
RuntimeEnv
->
summary
.
discardBlocks
+=
1
;
p
Cost
->
discardBlocks
+=
1
;
qDebug
(
"QInfo:%p data block discard, brange:%"
PRId64
"-%"
PRId64
", rows:%d"
,
GET_QINFO_ADDR
(
pRuntimeEnv
),
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
ekey
,
pBlockInfo
->
rows
);
(
*
status
)
=
BLK_DATA_DISCARD
;
}
p
RuntimeEnv
->
summary
.
totalCheckedRows
+=
pBlockInfo
->
rows
;
p
RuntimeEnv
->
summary
.
loadBlocks
+=
1
;
p
Cost
->
totalCheckedRows
+=
pBlockInfo
->
rows
;
p
Cost
->
loadBlocks
+=
1
;
*
pDataBlock
=
tsdbRetrieveDataBlock
(
pQueryHandle
,
NULL
);
if
(
*
pDataBlock
==
NULL
)
{
return
terrno
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录