Query Profile Action

Request

GET /rest/v2/manager/query/query_info

GET /rest/v2/manager/query/sql/{query_id}

GET /rest/v2/manager/query/profile/text/{query_id}

GET /rest/v2/manager/query/profile/fragments/{query_id}

GET /rest/v2/manager/query/profile/graph/{query_id}

获取查询信息

GET /rest/v2/manager/query/query_info

Description

可获取集群所有 fe 节点 select 查询信息。

Query parameters

  • query_id

可选,指定返回查询的queryID, 默认返回所有查询的信息。 - search

可选,指定返回包含字符串的查询信息,目前仅进行字符串匹配。 - is_all_node

可选,若为 true 则返回所有fe节点的查询信息,若为 false 则返回当前fe节点的查询信息。默认为true。

Response

1. {
2. "msg": "success",
3. "code": 0,
4. "data": {
5. "column_names": [
6. "Query ID",
7. "FE节点",
8. "查询用户",
9. "执行数据库",
10. "Sql",
11. "查询类型",
12. "开始时间",
13. "结束时间",
14. "执行时长",
15. "状态"
16. ],
17. "rows": [
18. [
19. ...
20. ]
21. ]
22. },
23. "count": 0
24. }

Examples

1. GET /rest/v2/manager/query/query_info

3. {
4. "msg": "success",
5. "code": 0,
6. "data": {
7. "column_names": [
8. "Query ID",
9. "FE节点",
10. "查询用户",
11. "执行数据库",
12. "Sql",
13. "查询类型",
14. "开始时间",
15. "结束时间",
16. "执行时长",
17. "状态"
18. ],
19. "rows": [
20. [
21. "d7c93d9275334c35-9e6ac5f295a7134b",
22. "127.0.0.1:8030",
23. "root",
24. "default_cluster:testdb",
25. "select c.id, c.name, p.age, p.phone, c.date, c.cost from cost c join people p on c.id = p.id where p.age > 20 order by c.id",
26. "Query",
27. "2021-07-29 16:59:12",
28. "2021-07-29 16:59:12",
29. "109ms",
30. "EOF"
31. ]
32. ]
33. },
34. "count": 0
35. }

获取指定查询的sql和文本profile

GET /rest/v2/manager/query/sql/{query_id}

GET /rest/v2/manager/query/profile/text/{query_id}

Description

用于获取指定query id的sql和profile文本。

Path parameters

  • query_id

query id。

Query parameters

  • is_all_node

可选,若为 true 则在所有fe节点中查询指定query id的信息,若为 false 则在当前连接的fe节点中查询指定query id的信息。默认为true。

Response

1. {
2. "msg": "success",
3. "code": 0,
4. "data": {
5. "sql": ""
6. },
7. "count": 0
8. }
1. {
2. "msg": "success",
3. "code": 0,
4. "data": {
5. "profile": ""
6. },
7. "count": 0
8. }

Examples

  1. 获取 sql:

``` 1. GET /rest/v2/manager/query/sql/d7c93d9275334c35-9e6ac5f295a7134b

  1. Response:
  2. {
  3. "msg": "success",
  4. "code": 0,
  5. "data": {
  6. "sql": "select c.id, c.name, p.age, p.phone, c.date, c.cost from cost c join people p on c.id = p.id where p.age > 20 order by c.id"
  7. },
  8. "count": 0
  9. } ```

获取指定查询fragment和instance信息

GET /rest/v2/manager/query/profile/fragments/{query_id}

Description

用于获取指定query id的fragment名称,instance id和执行时长。

Path parameters

  • query_id

query id。

Query parameters

  • is_all_node

可选,若为 true 则在所有fe节点中查询指定query id的信息,若为 false 则在当前连接的fe节点中查询指定query id的信息。默认为true。

Response

1. {
2. "msg": "success",
3. "code": 0,
4. "data": [
5. {
6. "fragment_id": "",
7. "time": "",
8. "instance_id": {
9. "": ""
10. }
11. }
12. ],
13. "count": 0
14. }

Examples

1. ```
2. GET /rest/v2/manager/query/profile/fragments/d7c93d9275334c35-9e6ac5f295a7134b

4. Response:
5. {
6. "msg": "success",
7. "code": 0,
8. "data": [
9. {
10. "fragment_id": "0",
11. "time": "36.169ms",
12. "instance_id": {
13. "d7c93d9275334c35-9e6ac5f295a7134e": "36.169ms"
14. }
15. },
16. {
17. "fragment_id": "1",
18. "time": "20.710ms",
19. "instance_id": {
20. "d7c93d9275334c35-9e6ac5f295a7134c": "20.710ms"
21. }
22. },
23. {
24. "fragment_id": "2",
25. "time": "7.83ms",
26. "instance_id": {
27. "d7c93d9275334c35-9e6ac5f295a7134d": "7.83ms"
28. }
29. }
30. ],
31. "count": 0
32. }
33. ```

获取指定query id树状profile信息

GET /rest/v2/manager/query/profile/graph/{query_id}

Description

获取指定query id树状profile信息,同 show query profile 指令。

Path parameters

  • query_id

query id。

Query parameters

  • fragment_id 和 instance_id

可选,这两个参数需同时指定或同时不指定。 同时不指定则返回profile 简易树形图,相当于show query profile '/query_id'; 同时指定则返回指定instance详细profile树形图,相当于show query profile '/query_id/fragment_id/instance_id'. - is_all_node

可选,若为 true 则在所有fe节点中查询指定query id的信息,若为 false 则在当前连接的fe节点中查询指定query id的信息。默认为true。

Response

1. {
2. "msg": "success",
3. "code": 0,
4. "data": {
5. "graph":""
6. },
7. "count": 0
8. }