Get SQL execution profile¶
View the execution profile for one SQL statement to analyze its execution steps and resource usage. By default, the API returns only records run by the current identity. With the required permission, it can return records for the entire workspace.
POST https://moi.matrixorigin.cn/newmoi/query/profile
Preparation before calling¶
Prepare a personal access token with access to the current workspace and the current workspace ID. First list SQL execution records, select the record to analyze, and note its statement ID and execution time.
Request body¶
curl -X POST "https://moi.matrixorigin.cn/newmoi/query/profile" \
-H "X-API-Key: $AI_STUDIO_API_KEY" \
-H "X-Workspace-ID: $WORKSPACE_ID" \
-H 'Content-Type: application/json' \
-d '{
"statement_id": "'"$STATEMENT_ID"'",
"start": "2026-08-26 09:44:00",
"end": "2026-08-26 09:46:00"
}'
Parameter |
Type |
Required |
Description |
|---|---|---|---|
statement_id |
string |
Yes |
Statement ID of the selected SQL execution record. |
start |
string |
Yes |
Query start time in |
end |
string |
Yes |
Query end time in |
scope |
string |
No |
View records for the current identity or the current workspace. |
Read scope
|
Records returned |
Permission |
|---|---|---|
self |
Records for the current identity. |
Default scope. |
workspace |
Workspace-wide records. |
Requires workspace audit read permission. |
Specify a query time range
You must specify both the start and end times, and the range must include the selected record’s execution time. This API uses the date-and-time format YYYY-MM-DD HH:MM:SS without a time zone. The time displayed in the list includes a time zone, so convert it before entering it here. For example, if the list displays 2026-08-26T09:45:35Z, you can use the range from 2026-08-26 09:44:00 through 2026-08-26 09:46:00.
Use the selected execution record
Enter the selected record’s statement ID in the statement ID field, and use a time range that includes the record’s execution time for the start and end time fields.
Success response¶
On success, the API returns an execution-profile result. If no execution profile was stored, the API still returns a successful response and indicates that no profile is available.
{
"code": "OK",
"msg": "OK",
"data": {
"statement_id": "5c6f22fb-ef0e-4f46-b06f-c31e1a7afb48",
"profile": {
"code": 200,
"message": "NO ExecPlan",
"success": false
}
}
}
Field |
Type |
Description |
|---|---|---|
code |
string |
|
msg |
string |
|
data.statement_id |
string |
Statement ID in the request. |
data.profile |
object |
Execution-profile result. |
data.profile.code |
integer |
Execution-profile status code. |
data.profile.message |
string |
Execution-profile message. |
data.profile.success |
boolean |
Whether an execution profile is available. |
data.profile.uuid |
string |
Execution-profile identifier. |
data.profile.steps |
object[] |
List of execution-profile steps. |
data.profile.steps[].step |
integer |
Step sequence number. |
data.profile.steps[].description |
string |
Step description. |
data.profile.steps[].state |
string |
Step status. |
data.profile.steps[].graphData |
object |
Execution-profile graph for the step. |
data.profile.steps[].graphData.nodes |
object[] |
Execution nodes and their resource statistics in the execution-profile graph. |
data.profile.steps[].graphData.edges |
object[] |
Data-flow relationships between execution nodes. |
data.profile.steps[].graphData.labels |
object[] |
Labels in the execution-profile graph. |
data.profile.steps[].graphData.global |
object |
Summary resource statistics for the step. |
Execution-profile steps and graph data are returned only when an execution profile is available.
Error response¶
{
"code": "ErrParamInvalid",
"msg": "Invalid request parameter",
"data": null
}
Field |
Type |
Description |
|---|---|---|
code |
string |
Error code. |
msg |
string |
Error message. |
data |
null |
— |
Next steps¶
If no execution profile is available, use the same statement ID and time range to get SQL execution details and check the SQL text and execution status.