Skip to main content
Skip to main content

Query Profile Action

Query Profile Action

Requestโ€‹

GET /rest/v2/manager/query/query_info

GET /rest/v2/manager/query/trace/{trace_id}

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

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

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

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

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

GET /rest/v2/manager/query/current_queries

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

Get the query informationโ€‹

GET /rest/v2/manager/query/query_info

Descriptionโ€‹

Gets information about select queries for all fe nodes in the cluster.

Query parametersโ€‹

  • query_id

    Optional, specifies the query ID of the query to be returned, default returns information for all queries.

  • search

    Optional, specifies that query information containing strings is returned, currently only string matches are performed.

  • is_all_node

    Optional, if true, returns query information for all fe nodes, if false, returns query information for the current fe node. The default is true.

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": {
"column_names": [
"Query ID",
"FE่Š‚็‚น",
"ๆŸฅ่ฏข็”จๆˆท",
"ๆ‰ง่กŒๆ•ฐๆฎๅบ“",
"Sql",
"ๆŸฅ่ฏข็ฑปๅž‹",
"ๅผ€ๅง‹ๆ—ถ้—ด",
"็ป“ๆŸๆ—ถ้—ด",
"ๆ‰ง่กŒๆ—ถ้•ฟ",
"็Šถๆ€"
],
"rows": [
[
...
]
]
},
"count": 0
}
SinceVersion 1.2

Admin ๅ’Œ Root ็”จๆˆทๅฏไปฅๆŸฅ็œ‹ๆ‰€ๆœ‰ Query.ๆ™ฎ้€š็”จๆˆทไป…่ƒฝๆŸฅ็œ‹่‡ชๅทฑๅ‘้€็š„ Query.

Examplesโ€‹

GET /rest/v2/manager/query/query_info

{
"msg": "success",
"code": 0,
"data": {
"column_names": [
"Query ID",
"FE่Š‚็‚น",
"ๆŸฅ่ฏข็”จๆˆท",
"ๆ‰ง่กŒๆ•ฐๆฎๅบ“",
"Sql",
"ๆŸฅ่ฏข็ฑปๅž‹",
"ๅผ€ๅง‹ๆ—ถ้—ด",
"็ป“ๆŸๆ—ถ้—ด",
"ๆ‰ง่กŒๆ—ถ้•ฟ",
"็Šถๆ€"
],
"rows": [
[
"d7c93d9275334c35-9e6ac5f295a7134b",
"127.0.0.1:8030",
"root",
"default_cluster:testdb",
"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",
"Query",
"2021-07-29 16:59:12",
"2021-07-29 16:59:12",
"109ms",
"EOF"
]
]
},
"count": 0
}

Get Query Id By Trace Idโ€‹

GET /rest/v2/manager/query/trace_id/{trace_id}

Descriptionโ€‹

Get query id by trance id.

Before executing a Query, set a unique trace id:

set session_context="trace_id:your_trace_id";

After executing the Query within the same Session, the query id can be obtained through the trace id.

Path parametersโ€‹

  • {trace_id}

    User specific trace id.

Query parametersโ€‹

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": "fb1d9737de914af1-a498d5c5dec638d3",
"count": 0
}
SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}

Get the sql and text profile for the specified queryโ€‹

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

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

Descriptionโ€‹

Get the sql and profile text for the specified query id.

Path parametersโ€‹

  • query_id

    The query id.

Query parametersโ€‹

  • is_all_node

    Optional, if true then query for the specified query id in all fe nodes, if false then query for the specified query id in the currently connected fe nodes. The default is true.

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": {
"sql": ""
},
"count": 0
}
{
"msg": "success",
"code": 0,
"data": {
"profile": ""
},
"count": 0
}
SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}
### Examples
  1. get sql.

    GET /rest/v2/manager/query/sql/d7c93d9275334c35-9e6ac5f295a7134b

    Response:
    {
    "msg": "success",
    "code": 0,
    "data": {
    "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"
    },
    "count": 0
    }

Get the specified query fragment and instance informationโ€‹

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

Descriptionโ€‹

Get the fragment name, instance id, host ip/port and execution time for the specified query id.

Path parametersโ€‹

  • query_id

    The query id.

Query parametersโ€‹

  • is_all_node

    Optional, if true then query for the specified query id in all fe nodes, if false then query for the specified query id in the currently connected fe nodes. The default is true.

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": [
{
"fragment_id": "",
"time": "",
"instance_id": {
"": {
"host": "",
"active_time": ""
}
}
}
],
"count": 0
}
SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}
### Examples
GET /rest/v2/manager/query/profile/fragments/d7c93d9275334c35-9e6ac5f295a7134b

Response:
{
"msg": "success",
"code": 0,
"data": [
{
"fragment_id": "0",
"time": "36.169ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134e": {
"host": "172.19.0.4:9060",
"active_time": "36.169ms"
}
}
},
{
"fragment_id": "1",
"time": "20.710ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134c": {
"host": "172.19.0.5:9060",
"active_time": "20.710ms"
}
}
},
{
"fragment_id": "2",
"time": "7.83ms",
"instance_id": {
"d7c93d9275334c35-9e6ac5f295a7134d": {
"host": "172.19.0.6:9060",
"active_time": "7.83ms"
},
"d7c93d9275334c35-9e6ac5f295a7134f": {
"host": "172.19.0.7:9060",
"active_time": "10.873ms"
}
}
}
],
"count": 0
}

Get the specified query id tree profile informationโ€‹

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

Descriptionโ€‹

Get the tree profile information of the specified query id, same as show query profile command.

Path parametersโ€‹

  • query_id

    The query id.

Query parametersโ€‹

  • fragment_id and instance_id

    Optional, both parameters must be specified or not.
    If both are not specified, a simple tree of profiles is returned, equivalent to show query profile '/query_id';
    If both are specified, a detailed profile tree is returned, which is equivalent to show query profile '/query_id/fragment_id/instance_id'.

  • is_all_node

    Optional, if true then query information about the specified query id in all fe nodes, if false then query information about the specified query id in the currently connected fe nodes. The default is true.

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": {
"graph":""
},
"count": 0
}
SinceVersion 1.2

Admin and Root user can view all queries. Ordinary users can only view the Query sent by themselves. If the specified trace id does not exist or has no permission, it will return Bad Request:

{
"msg": "Bad Request",
"code": 403,
"data": "error messages",
"count": 0
}

Current running queriesโ€‹

GET /rest/v2/manager/query/current_queries

Descriptionโ€‹

Same as show proc "/current_query_stmts", return current running queries.

Path parametersโ€‹

Query parametersโ€‹

  • is_all_node

    Optional. Return current running queries from all FE if set to true. Default is true.

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": {
"columnNames": ["Frontend", "QueryId", "ConnectionId", "Database", "User", "ExecTime", "SqlHash", "Statement"],
"rows": [
["172.19.0.3", "108e47ab438a4560-ab1651d16c036491", "2", "", "root", "6074", "1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)"],
["172.19.0.11", "3606cad4e34b49c6-867bf6862cacc645", "3", "", "root", "9306", "1a35f62f4b14b9d7961b057b77c3102f", "select sleep(60)"]
]
},
"count": 0
}

Cancel queryโ€‹

POST /rest/v2/manager/query/kill/{query_id}

Descriptionโ€‹

Cancel query of specified connection.

Path parametersโ€‹

  • {query_id}

    query id. You can get query id by trance_id api.

Query parametersโ€‹

Responseโ€‹

{
"msg": "success",
"code": 0,
"data": null,
"count": 0
}