Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
31e29dfc
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
31e29dfc
编写于
7月 15, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: the query uses the 'cachelast' option to decide whether to optimize the last_row function
上级
ef4f6964
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
10 deletion
+33
-10
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+1
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+3
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+23
-9
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-0
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+2
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+2
-0
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
31e29dfc
...
...
@@ -77,6 +77,7 @@ typedef struct SScanLogicNode {
SArray
*
pSmaIndexes
;
SNodeList
*
pGroupTags
;
bool
groupSort
;
int8_t
cacheLastMode
;
}
SScanLogicNode
;
typedef
struct
SJoinLogicNode
{
...
...
include/libs/nodes/querynodes.h
浏览文件 @
31e29dfc
...
...
@@ -152,6 +152,7 @@ typedef struct SRealTableNode {
char
qualDbName
[
TSDB_DB_NAME_LEN
];
// SHOW qualDbName.TABLES
double
ratio
;
SArray
*
pSmaIndexes
;
int8_t
cacheLastMode
;
}
SRealTableNode
;
typedef
struct
STempTableNode
{
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
31e29dfc
...
...
@@ -140,6 +140,9 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, SRealTa
if
(
TSDB_CODE_SUCCESS
==
code
&&
(
0
==
strcmp
(
pRealTable
->
table
.
tableName
,
TSDB_INS_TABLE_DNODE_VARIABLES
)))
{
code
=
reserveDnodeRequiredInCache
(
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pRealTable
->
table
.
dbName
,
pCxt
->
pMetaCache
);
}
return
code
;
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
31e29dfc
...
...
@@ -1772,6 +1772,15 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
setTableCacheLastMode
(
STranslateContext
*
pCxt
,
SName
*
pName
,
SRealTableNode
*
pRealTable
)
{
SDbCfgInfo
dbCfg
=
{
0
};
int32_t
code
=
getDBCfg
(
pCxt
,
pRealTable
->
table
.
dbName
,
&
dbCfg
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pRealTable
->
cacheLastMode
=
dbCfg
.
cacheLast
;
}
return
code
;
}
static
int32_t
translateTable
(
STranslateContext
*
pCxt
,
SNode
*
pTable
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pTable
))
{
...
...
@@ -1791,6 +1800,9 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setTableIndex
(
pCxt
,
&
name
,
pRealTable
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setTableCacheLastMode
(
pCxt
,
&
name
,
pRealTable
);
}
}
pRealTable
->
table
.
precision
=
pRealTable
->
pMeta
->
tableInfo
.
precision
;
pRealTable
->
table
.
singleTable
=
isSingleTable
(
pRealTable
);
...
...
@@ -5413,11 +5425,12 @@ static int32_t rewriteCreateTable(STranslateContext* pCxt, SQuery* pQuery) {
}
static
void
addCreateTbReqIntoVgroup
(
int32_t
acctId
,
SHashObj
*
pVgroupHashmap
,
SCreateSubTableClause
*
pStmt
,
const
STag
*
pTag
,
uint64_t
suid
,
const
char
*
sTableNmae
,
SVgroupInfo
*
pVgInfo
,
SArray
*
tagName
)
{
// char dbFName[TSDB_DB_FNAME_LEN] = {0};
// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
// strcpy(name.dbname, pStmt->dbName);
// tNameGetFullDbName(&name, dbFName);
const
STag
*
pTag
,
uint64_t
suid
,
const
char
*
sTableNmae
,
SVgroupInfo
*
pVgInfo
,
SArray
*
tagName
)
{
// char dbFName[TSDB_DB_FNAME_LEN] = {0};
// SName name = {.type = TSDB_DB_NAME_T, .acctId = acctId};
// strcpy(name.dbname, pStmt->dbName);
// tNameGetFullDbName(&name, dbFName);
struct
SVCreateTbReq
req
=
{
0
};
req
.
type
=
TD_CHILD_TABLE
;
...
...
@@ -5524,7 +5537,7 @@ static int32_t buildNormalTagVal(STranslateContext* pCxt, SSchema* pTagSchema, S
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
)
{
void
*
nodeVal
=
nodesGetValueFromNode
(
pVal
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
// strcpy(val.colName, pTagSchema->name);
// strcpy(val.colName, pTagSchema->name);
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
val
.
pData
=
varDataVal
(
nodeVal
);
val
.
nData
=
varDataLen
(
nodeVal
);
...
...
@@ -5621,7 +5634,7 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau
}
else
if
(
pVal
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_NULL
&&
!
pVal
->
isNull
)
{
char
*
tmpVal
=
nodesGetValueFromNode
(
pVal
);
STagVal
val
=
{.
cid
=
pTagSchema
->
colId
,
.
type
=
pTagSchema
->
type
};
// strcpy(val.colName, pTagSchema->name);
// strcpy(val.colName, pTagSchema->name);
if
(
IS_VAR_DATA_TYPE
(
pTagSchema
->
type
))
{
val
.
pData
=
varDataVal
(
tmpVal
);
val
.
nData
=
varDataLen
(
tmpVal
);
...
...
@@ -5664,7 +5677,7 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
code
=
getTableMeta
(
pCxt
,
pStmt
->
useDbName
,
pStmt
->
useTableName
,
&
pSuperTableMeta
);
}
STag
*
pTag
=
NULL
;
STag
*
pTag
=
NULL
;
SArray
*
tagName
=
taosArrayInit
(
8
,
TSDB_COL_NAME_LEN
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -5680,7 +5693,8 @@ static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableCla
code
=
getTableHashVgroup
(
pCxt
,
pStmt
->
dbName
,
pStmt
->
tableName
,
&
info
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
addCreateTbReqIntoVgroup
(
pCxt
->
pParseCxt
->
acctId
,
pVgroupHashmap
,
pStmt
,
pTag
,
pSuperTableMeta
->
uid
,
pStmt
->
useTableName
,
&
info
,
tagName
);
addCreateTbReqIntoVgroup
(
pCxt
->
pParseCxt
->
acctId
,
pVgroupHashmap
,
pStmt
,
pTag
,
pSuperTableMeta
->
uid
,
pStmt
->
useTableName
,
&
info
,
tagName
);
}
taosArrayDestroy
(
tagName
);
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
31e29dfc
...
...
@@ -244,6 +244,7 @@ static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealT
pScan
->
showRewrite
=
pCxt
->
pPlanCxt
->
showRewrite
;
pScan
->
ratio
=
pRealTable
->
ratio
;
pScan
->
dataRequired
=
FUNC_DATA_REQUIRED_DATA_LOAD
;
pScan
->
cacheLastMode
=
pRealTable
->
cacheLastMode
;
*
pLogicNode
=
(
SLogicNode
*
)
pScan
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
31e29dfc
...
...
@@ -1985,7 +1985,8 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
if
(
QUERY_NODE_LOGIC_PLAN_AGG
!=
nodeType
(
pNode
)
||
!
(((
SAggLogicNode
*
)
pNode
)
->
hasLastRow
)
||
NULL
!=
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
||
1
!=
LIST_LENGTH
(
pNode
->
pChildren
)
||
QUERY_NODE_LOGIC_PLAN_SCAN
!=
nodeType
(
nodesListGetNode
(
pNode
->
pChildren
,
0
))
||
NULL
!=
((
SScanLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
))
->
node
.
pConditions
)
{
NULL
!=
((
SScanLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
))
->
node
.
pConditions
||
0
==
((
SScanLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
))
->
cacheLastMode
)
{
return
false
;
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
31e29dfc
...
...
@@ -515,6 +515,8 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu
}
pScan
->
groupSort
=
pScanLogicNode
->
groupSort
;
vgroupInfoToNodeAddr
(
pScanLogicNode
->
pVgroupList
->
vgroups
,
&
pSubplan
->
execNode
);
return
createScanPhysiNodeFinalize
(
pCxt
,
pSubplan
,
pScanLogicNode
,
(
SScanPhysiNode
*
)
pScan
,
pPhyNode
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录