Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
35f8a337
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看板
提交
35f8a337
编写于
3月 30, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
08bd344d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
27 addition
and
23 deletion
+27
-23
include/util/tdef.h
include/util/tdef.h
+1
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-0
source/libs/qcom/inc/queryInt.h
source/libs/qcom/inc/queryInt.h
+5
-7
source/libs/qcom/src/queryExplain.c
source/libs/qcom/src/queryExplain.c
+18
-15
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+2
-1
未找到文件。
include/util/tdef.h
浏览文件 @
35f8a337
...
...
@@ -389,6 +389,7 @@ typedef enum ELogicConditionType {
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN"
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE 5
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
35f8a337
...
...
@@ -1944,6 +1944,7 @@ int32_t qExtractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** p
}
(
*
pSchema
)[
0
].
type
=
TSDB_DATA_TYPE_BINARY
;
(
*
pSchema
)[
0
].
bytes
=
TSDB_EXPLAIN_RESULT_ROW_SIZE
;
strcpy
((
*
pSchema
)[
0
].
name
,
TSDB_EXPLAIN_RESULT_COLUMN_NAME
);
}
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/qcom/inc/queryInt.h
浏览文件 @
35f8a337
...
...
@@ -22,8 +22,6 @@ extern "C" {
#include "nodes.h"
#include "plannodes.h"
#define QUERY_EXPLAIN_MAX_RES_LEN 1024
//newline area
#define EXPLAIN_TAG_SCAN_FORMAT "Tag scan on %s columns=%d"
#define EXPLAIN_TBL_SCAN_FORMAT "Table scan on %s columns=%d"
...
...
@@ -42,8 +40,8 @@ extern "C" {
#define EXPLAIN_TIMERANGE_FORMAT "Time range: [%" PRId64 ", %" PRId64 "]"
//append area
#define EXPLAIN_LOOPS_FORMAT "loops
%d"
#define EXPLAIN_REVERSE_FORMAT "reverse
%d"
#define EXPLAIN_LOOPS_FORMAT "loops
=
%d"
#define EXPLAIN_REVERSE_FORMAT "reverse
=
%d"
typedef
struct
SExplainResNode
{
...
...
@@ -68,11 +66,11 @@ typedef struct SExplainRowCtx {
#define EXPLAIN_ROW_NEW(level, ...) \
do { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE,
QUERY_EXPLAIN_MAX_RES_LEN, "%*s", level
, ""); \
tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen,
QUERY_EXPLAIN_MAX_RES_LEN
- tlen, __VA_ARGS__); \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE,
TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2
, ""); \
tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen,
TSDB_EXPLAIN_RESULT_ROW_SIZE
- tlen, __VA_ARGS__); \
} while (0)
#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen,
QUERY_EXPLAIN_MAX_RES_LEN
- tlen, __VA_ARGS__)
#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen,
TSDB_EXPLAIN_RESULT_ROW_SIZE
- tlen, __VA_ARGS__)
#define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; } while (0)
#define QRY_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
...
...
source/libs/qcom/src/queryExplain.c
浏览文件 @
35f8a337
...
...
@@ -204,12 +204,13 @@ int32_t qExplainBufAppendExecInfo(void *pExecInfo, char *tbuf, int32_t *len) {
int32_t
qExplainResAppendRow
(
SExplainRowCtx
*
ctx
,
char
*
tbuf
,
int32_t
len
,
int32_t
level
)
{
SQueryExplainRowInfo
row
=
{
0
};
row
.
buf
=
strdup
(
tbuf
);
row
.
buf
=
taosMemoryMalloc
(
len
);
if
(
NULL
==
row
.
buf
)
{
qError
(
"
strdup %s failed"
,
tbuf
);
qError
(
"
taosMemoryMalloc %d failed"
,
len
);
QRY_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
memcpy
(
row
.
buf
,
tbuf
,
len
);
row
.
level
=
level
;
row
.
len
=
len
;
ctx
->
totalSize
+=
len
;
...
...
@@ -275,7 +276,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pTblScanNode
->
scan
.
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pTblScanNode
->
scan
.
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pTblScanNode
->
scan
.
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -310,7 +311,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pPrjNode
->
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pPrjNode
->
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pPrjNode
->
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -327,13 +328,13 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pJoinNode
->
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pJoinNode
->
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pJoinNode
->
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_ON_CONDITIONS_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pJoinNode
->
pOnConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pJoinNode
->
pOnConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
break
;
...
...
@@ -349,7 +350,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pAggNode
->
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pAggNode
->
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pAggNode
->
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -366,7 +367,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pExchNode
->
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pExchNode
->
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pExchNode
->
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -383,7 +384,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pSortNode
->
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pSortNode
->
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pSortNode
->
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -407,7 +408,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pIntNode
->
window
.
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pIntNode
->
window
.
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pIntNode
->
window
.
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -424,7 +425,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainRowCtx *ctx
if
(
pIntNode
->
window
.
node
.
pConditions
)
{
EXPLAIN_ROW_NEW
(
level
+
1
,
EXPLAIN_FILTER_FORMAT
);
QRY_ERR_RET
(
nodesNodeToSQL
(
pIntNode
->
window
.
node
.
pConditions
,
tbuf
,
QUERY_EXPLAIN_MAX_RES_LEN
,
&
tlen
));
QRY_ERR_RET
(
nodesNodeToSQL
(
pIntNode
->
window
.
node
.
pConditions
,
tbuf
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
,
&
tlen
));
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
...
...
@@ -463,9 +464,9 @@ int32_t qGenerateExplainResRowsFromNode(SExplainResNode *pResNode, SExplainRowCt
}
int32_t
code
=
0
;
char
*
tbuf
=
taosMemoryMalloc
(
QUERY_EXPLAIN_MAX_RES_LEN
);
char
*
tbuf
=
taosMemoryMalloc
(
TSDB_EXPLAIN_RESULT_ROW_SIZE
);
if
(
NULL
==
tbuf
)
{
qError
(
"malloc size %d failed"
,
QUERY_EXPLAIN_MAX_RES_LEN
);
qError
(
"malloc size %d failed"
,
TSDB_EXPLAIN_RESULT_ROW_SIZE
);
QRY_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -536,9 +537,9 @@ int32_t qGetExplainRspFromRowCtx(void *ctx, SRetrieveTableRsp **pRsp) {
}
rsp
->
completed
=
1
;
rsp
->
numOfRows
=
rowNum
;
rsp
->
numOfRows
=
htonl
(
rowNum
)
;
*
(
int32_t
*
)
rsp
->
data
=
pCtx
->
totalSize
;
*
(
int32_t
*
)
rsp
->
data
=
htonl
(
pCtx
->
totalSize
)
;
int32_t
*
offset
=
(
int32_t
*
)((
char
*
)
rsp
->
data
+
sizeof
(
int32_t
));
char
*
data
=
(
char
*
)(
offset
+
rowNum
);
...
...
@@ -555,6 +556,8 @@ int32_t qGetExplainRspFromRowCtx(void *ctx, SRetrieveTableRsp **pRsp) {
data
+=
row
->
len
;
}
*
pRsp
=
rsp
;
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
35f8a337
...
...
@@ -2261,6 +2261,7 @@ int32_t schStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, i
pJob
->
sql
=
sql
;
pJob
->
attr
.
queryJob
=
true
;
pJob
->
attr
.
explainMode
=
pDag
->
explainInfo
.
mode
;
SCH_ERR_JRET
(
schValidateAndBuildJobExplain
(
pDag
,
pJob
));
...
...
@@ -2528,7 +2529,7 @@ int32_t schedulerFetchRows(int64_t job, void **pData) {
SCH_JOB_DLOG
(
"job already succeed, status:%s"
,
jobTaskStatusStr
(
status
));
goto
_return
;
}
else
if
(
status
==
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
if
(
!
pJob
->
attr
.
explainMode
==
EXPLAIN_MODE_STATIC
)
{
if
(
!
(
pJob
->
attr
.
explainMode
==
EXPLAIN_MODE_STATIC
)
)
{
SCH_ERR_JRET
(
schFetchFromRemote
(
pJob
));
tsem_wait
(
&
pJob
->
rspSem
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录