Exporting Top SQL Statements
Function
This API is used to export top SQL statements. Before calling this API:
- Learn how to authenticate this API.
- Obtain the required region and endpoint.
Constraints
This API is only available for nodes with CNs or DNs (primary or standby DNs) deployed.
Debugging
You can debug this API in API Explorer.
URI
POST /v3/{project_id}/instances/{instance_id}/top-sql-list/export
|
Parameter |
Mandatory |
Description |
|---|---|---|
|
project_id |
Yes |
Definition Project ID of a tenant in a region. To obtain the value, see Obtaining a Project ID. Constraints N/A Range The value can contain 32 characters. Only letters and digits are allowed. Default Value N/A |
|
instance_id |
Yes |
Definition Instance ID, which uniquely identifies an instance. Constraints N/A Range The value can contain 36 characters. Only letters and digits are allowed. Default Value N/A |
Request Parameters
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
X-Auth-Token |
Yes |
String |
Definition User token. You can obtain the token by calling the IAM API used to obtain a user token. After a response is returned, the value of X-Subject-Token in the response header is the token. Constraints N/A Range N/A Default Value N/A |
|
X-Language |
No |
String |
Definition Language. Constraints N/A Range
Default Value en-us |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
instance_id |
Yes |
String |
Definition Instance ID. Constraints N/A Range N/A Default Value N/A |
|
node_ids |
Yes |
Array of strings |
Definition IDs of selected instance nodes. Constraints N/A |
|
start_time |
Yes |
Long |
Definition Start time. Constraints The value is a 13-digit UNIX timestamp, in milliseconds. The time zone is UTC. Range N/A Default Value N/A |
|
end_time |
Yes |
Long |
Definition End time. Constraints The value is a 13-digit UNIX timestamp, in milliseconds. The time zone is UTC. Range N/A Default Value N/A |
|
start_time_utc |
No |
String |
Definition Start time. Constraints UTC time. Range N/A Default Value N/A |
|
end_time_utc |
No |
String |
Definition End time. Constraints UTC time. Range N/A Default Value N/A |
|
support_system |
No |
Boolean |
Definition Whether to display system users. Constraints N/A Range
Default Value N/A |
|
sql_id |
No |
String |
Definition ID of a normalized top SQL statement. Constraints N/A Range N/A Default Value N/A |
|
db_name |
No |
String |
Definition Name of the database where a top SQL statement is executed. Constraints This parameter is displayed only when the DB engine version is 8.200 or later. Range N/A Default Value N/A |
|
user_name |
No |
String |
Definition Name of the user who executed a top SQL statement. Constraints N/A Range N/A Default Value N/A |
|
sql_text |
No |
String |
Definition Text of top SQL statements. Constraints N/A Range N/A Default Value N/A |
|
multi_queries |
No |
Array of objects |
Definition Query conditions for field aggregation. For details, see Table 4. Constraints Only all-AND or all-OR queries can be performed on the query field. |
|
Parameter |
Mandatory |
Type |
Description |
|---|---|---|---|
|
name |
Yes |
String |
Definition Name of the field to be queried. Constraints Only the character string query is supported. Range 1 to 128 characters, including letters (case-sensitive), digits, and underscores (_) Default Value N/A |
|
condition |
Yes |
String |
Definition Combined condition. Constraints N/A Range The value can only be and, or, AND or OR. Default Value N/A |
|
values |
Yes |
Array of strings |
Definition Set of multiple search criteria. The value is a list of 1 to 5 characters. Constraints N/A |
|
is_fuzzy |
No |
Boolean |
Definition Set of multiple search criteria. Constraints The value can only be true for fuzzy query. Range
Default Value true |
Response Parameters
None
Example Request
POST https://gaussdb-opengauss.ap-southeast-1.myhuaweicloud.com/v3/0611f1bd8b00d5d32f17c017f15b599f/instances/3d39c18788b54a919bab633874c159dfin14/top-sql-list/export
{
"instance_id": "3d39c18788b54a919bab633874c159dfin14",
"node_ids": [
"ce86fdea77304bfb9469d0b75ea3943ano14"
],
"start_time": 1745477837000,
"end_time": 1745564237000,
"start_time_utc": "2025-04-24T06:57:17+0000",
"end_time_utc": "2025-04-25T06:57:17+0000",
"user_name": "dbmind_server",
"sql_text": "BEGIN",
"sql_id": "1872435845",
"db_name": "postgres",
"support_system": false,
"multi_queries": [
{
"name": "query",
"condition": "AND",
"is_fuzzy": true,
"values": [
"BEGIN"
]
}
]
}
Example Response
None
Status Codes
- Normal
- Abnormal
For details, see Status Codes.
Error Codes
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot