查询SQL执行信息
功能介绍
查询SQL执行信息。
调用方法
请参见如何调用API。
URI
GET /v1/{project_id}/clusters/{cluster_id}/dms/queries/{query_id}
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
project_id |
是 |
String |
参数解释: 项目ID。获取方法请参见获取项目ID。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
cluster_id |
是 |
String |
参数解释: 集群ID。获取方法请参见获取集群ID。 约束限制: 必须是有效的dws集群ID。 取值范围: 36位UUID。 默认取值: 不涉及。 |
query_id |
是 |
String |
参数解释: 查询ID。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
参数 |
是否必选 |
参数类型 |
描述 |
---|---|---|---|
ctime |
否 |
Long |
参数解释: 采集时间,时间戳。 约束限制: 不涉及。 取值范围: 不涉及。 默认取值: 不涉及。 |
请求参数
无
响应参数
状态码:200
参数 |
参数类型 |
描述 |
---|---|---|
code |
Integer |
参数解释: 响应码。 取值范围: 不涉及。 |
msg |
String |
参数解释: 响应信息。 取值范围: 不涉及。 |
data |
ListQueriesDto object |
参数解释: 响应数据。 取值范围: 不涉及。 |
参数 |
参数类型 |
描述 |
---|---|---|
virtual_cluster_id |
Integer |
参数解释: 虚拟集群ID。 取值范围: 不涉及。 |
ctime |
Long |
参数解释: 采集时间。 取值范围: 不涉及。 |
pid |
String |
参数解释: 会话ID。 取值范围: 不涉及。 |
inst_name |
String |
参数解释: 实例名称。 取值范围: 不涉及。 |
waiting |
Boolean |
参数解释: 如果后台当前正等待锁则为true。 取值范围: 不涉及。 |
enqueue |
String |
参数解释: 资源状态。 取值范围: 不涉及。 |
warning |
String |
参数解释: 主要显示如下几类告警信息以及sql自诊断调优相关告警。 取值范围: 不涉及。 |
query |
String |
参数解释: 查询语句。 取值范围: 不涉及。 |
lane |
String |
参数解释: 快慢车道。 取值范围: fast:快车道。 slow:慢车道。 |
db_name |
String |
参数解释: 数据库名称。 取值范围: 不涉及。 |
priority |
String |
参数解释: 任务在资源池中的优先级。 取值范围: 1:最高。 2:高。 4:中。 8:低。 |
query_id |
String |
参数解释: 语句执行使用的内部查询ID。 取值范围: 不涉及。 |
query_band |
String |
参数解释: 用于标示作业类型,可通过guc参数query_band进行设置,默认为空字符串。 取值范围: 不涉及。 |
job_name |
String |
参数解释: 该值是从query_band的字段中取出来的,位置0。 取值范围: 不涉及。 |
job_inst |
String |
参数解释: 该值是从query_band的字段中取出来的,位置1。 取值范围: 不涉及。 |
user_name |
String |
参数解释: 连接到后端的用户名。 取值范围: 不涉及。 |
application_name |
String |
参数解释: 连接到后端的应用名。 取值范围: 不涉及。 |
client_address |
String |
参数解释: 连接到后端的客户端的IP地址。 取值范围: 不涉及。 |
client_hostname |
String |
参数解释: 客户端的主机名。 取值范围: 不涉及。 |
client_port |
String |
参数解释: 客户端用于与后端通讯的tcp端口号。 取值范围: 不涉及。 |
start_time |
Long |
参数解释: 语句执行的开始时间。 取值范围: 不涉及。 |
block_time |
Long |
参数解释: 语句执行前的阻塞时间,单位ms。 取值范围: 不涉及。 |
duration |
Long |
参数解释: 语句已经执行的时间,单位ms。 取值范围: 不涉及。 |
estimate_total_time |
Long |
参数解释: 语句执行预估总时间,单位ms。 取值范围: 不涉及。 |
estimate_left_time |
Long |
参数解释: 语句执行预估剩余时间,单位ms。 取值范围: 不涉及。 |
resource_pool |
String |
参数解释: 用户使用的资源池。 取值范围: 不涉及。 |
control_group |
String |
参数解释: 语句所使用的cgroup。 取值范围: 不涉及。 |
min_peak_memory |
Integer |
参数解释: 语句在所有dn上的最小内存峰值,单位mb。 取值范围: 不涉及。 |
max_peak_memory |
Integer |
参数解释: 语句在所有dn上的最大内存峰值,单位mb。 取值范围: 不涉及。 |
average_peak_memory |
Integer |
参数解释: 语句执行过程中的内存使用平均值,单位mb。 取值范围: 不涉及。 |
memory_skew_percent |
Integer |
参数解释: 语句在各dn间的内存使用倾斜率。 取值范围: 不涉及。 |
estimate_memory |
Integer |
参数解释: 语句预估使用内存,单位mb。 取值范围: 不涉及。 |
spill_info |
String |
参数解释: 语句在所有dn上的下盘信息。 取值范围: 不涉及。 |
min_spill_size |
Integer |
参数解释: 若发生下盘,所有dn上下盘的最小数据量 (单位mb) 默认为0。 取值范围: 不涉及。 |
max_spill_size |
Integer |
参数解释: 若发生下盘,所有dn上下盘的最大数据量 (单位mb) 默认为0。 取值范围: 不涉及。 |
average_spill_size |
Integer |
参数解释: 若发生下盘,所有dn上下盘的平均数据量 (单位mb) 默认为0。 取值范围: 不涉及。 |
spill_skew_percent |
Integer |
参数解释: 若发生下盘,dn间下盘倾斜率。 取值范围: 不涉及。 |
min_dn_time |
Long |
参数解释: 语句在所有dn上的最小执行时间,单位ms。 取值范围: 不涉及。 |
max_dn_time |
Long |
参数解释: 语句在所有dn上的最大执行时间,单位ms。 取值范围: 不涉及。 |
average_dn_time |
Long |
参数解释: 语句在所有dn上的平均执行时间,单位ms。 取值范围: 不涉及。 |
dntime_skew_percent |
Integer |
参数解释: 语句在各dn间的执行时间倾斜率。 取值范围: 不涉及。 |
min_cpu_time |
Long |
参数解释: 语句在所有dn上的最小cpu时间,单位ms。 取值范围: 不涉及。 |
max_cpu_time |
Long |
参数解释: 语句在所有dn上的最大cpu时间,单位ms。 取值范围: 不涉及。 |
total_cpu_time |
Long |
参数解释: 语句在所有dn上的cpu总时间,单位ms。 取值范围: 不涉及。 |
cpu_skew_percent |
Integer |
参数解释: 语句在各dn间的cpu时间倾斜率。 取值范围: 不涉及。 |
average_peak_iops |
Integer |
参数解释: 语句在所有dn上的每秒平均io峰值(列存单位是次/s,行存单位是万次/s)。 取值范围: 不涉及。 |
iops_skew_percent |
Integer |
参数解释: 语句在dn间的io倾斜率。 取值范围: 不涉及。 |
max_peak_iops |
Integer |
参数解释: 语句在所有dn上的每秒最大io峰值(列存单位是次/s,行存单位是万次/s)。 取值范围: 不涉及。 |
min_peak_iops |
Integer |
参数解释: 语句在所有dn上的每秒最小io峰值(列存单位是次/s,行存单位是万次/s)。 取值范围: 不涉及。 |
query_plan |
String |
参数解释: 查询计划。 取值范围: 不涉及。 |
query_status |
String |
参数解释: 当前查询语句的实时运行状态。 取值范围: active,idle,idle in transaction,idle in transaction(aborted),fastpath function call,disabled。 |
wlm_status |
String |
参数解释: 当前查询语句在资源池上的运行状态。 取值范围: pending:待生效。 running:运行中。 finished:结束。 aborted:终止。 active:正常。 unknown:未知。 |
wlm_attrib |
String |
参数解释: 语句的属性。 取值范围: ordinary:普通。 simple:简单。 complicated:复杂。 internal:内部。 |
system_query |
Boolean |
参数解释: 是否系统查询。 取值范围: 不涉及。 |
backend_start |
Long |
参数解释: 该过程开始的时间,即当客户端连接服务器时。 取值范围: 不涉及。 |
elapsed_time |
Long |
参数解释: 到目前为止的执行时间。 取值范围: 不涉及。 |
curr_xact_start |
Long |
参数解释: 启动当前事务的时间,如果没有事务是活跃的,则为null。如果当前查询是首个事务,则这列等同于query_start列。 取值范围: 不涉及。 |
state_change |
Long |
参数解释: 上次状态改变的时间。 取值范围: 不涉及。 |
query_start |
Long |
参数解释: 语句执行的开始时间。 取值范围: 不涉及。 |
query_elapsed_time |
Long |
参数解释: 语句当前为止的实际执行时间。单位:秒。 取值范围: 不涉及。 |
请求示例
https://{Endpoint}/v1/{project_id}/clusters/{cluster_id}/dms/queries/{query_id}?ctime=1699062846000
响应示例
状态码:200
查询成功。
{
"code" : 0,
"msg" : "OK",
"data" : {
"ctime" : 1699062846000,
"pid" : "140535026615872",
"waiting" : false,
"duration" : 0,
"enqueue" : "",
"warning" : "",
"query" : "WLM fetch collect info from data nodes",
"lane" : "",
"priority" : null,
"virtual_cluster_id" : 0,
"inst_name" : "cn_5002",
"db_name" : "postgres",
"query_id" : "145522562959855061",
"query_band" : "",
"job_name" : "",
"job_inst" : "",
"user_name" : "Ruby",
"application_name" : "workload",
"client_address" : "",
"client_hostname" : "",
"client_port" : "",
"start_time" : 0,
"block_time" : 0,
"estimate_total_time" : 0,
"estimate_left_time" : 0,
"resource_pool" : "default_pool",
"control_group" : "",
"min_peak_memory" : 0,
"max_peak_memory" : 0,
"average_peak_memory" : 0,
"memory_skew_percent" : 0,
"estimate_memory" : 0,
"spill_info" : "",
"min_spill_size" : 0,
"max_spill_size" : 0,
"average_spill_size" : 0,
"spill_skew_percent" : 0,
"min_dn_time" : 0,
"max_dn_time" : 0,
"average_dn_time" : 0,
"dntime_skew_percent" : 0,
"min_cpu_time" : 0,
"max_cpu_time" : 0,
"total_cpu_time" : 0,
"cpu_skew_percent" : 0,
"average_peak_iops" : 0,
"iops_skew_percent" : 0,
"max_peak_iops" : 0,
"min_peak_iops" : 0,
"query_plan" : "",
"query_status" : "active",
"wlm_status" : "",
"wlm_attrib" : "",
"system_query" : false,
"backend_start" : 0,
"elapsed_time" : 0,
"curr_xact_start" : 0,
"state_change" : 0,
"query_start" : 0,
"query_elapsed_time" : 0
}
}
SDK代码示例
SDK代码示例如下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dws.v2.region.DwsRegion;
import com.huaweicloud.sdk.dws.v2.*;
import com.huaweicloud.sdk.dws.v2.model.*;
public class ShowQueryDetailSolution {
public static void main(String[] args) {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
String ak = System.getenv("CLOUD_SDK_AK");
String sk = System.getenv("CLOUD_SDK_SK");
String projectId = "{project_id}";
ICredential auth = new BasicCredentials()
.withProjectId(projectId)
.withAk(ak)
.withSk(sk);
DwsClient client = DwsClient.newBuilder()
.withCredential(auth)
.withRegion(DwsRegion.valueOf("<YOUR REGION>"))
.build();
ShowQueryDetailRequest request = new ShowQueryDetailRequest();
request.withClusterId("{cluster_id}");
request.withQueryId("{query_id}");
try {
ShowQueryDetailResponse response = client.showQueryDetail(request);
System.out.println(response.toString());
} catch (ConnectionException e) {
e.printStackTrace();
} catch (RequestTimeoutException e) {
e.printStackTrace();
} catch (ServiceResponseException e) {
e.printStackTrace();
System.out.println(e.getHttpStatusCode());
System.out.println(e.getRequestId());
System.out.println(e.getErrorCode());
System.out.println(e.getErrorMsg());
}
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdws.v2 import *
if __name__ == "__main__":
# The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
# In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak = os.environ["CLOUD_SDK_AK"]
sk = os.environ["CLOUD_SDK_SK"]
projectId = "{project_id}"
credentials = BasicCredentials(ak, sk, projectId)
client = DwsClient.new_builder() \
.with_credentials(credentials) \
.with_region(DwsRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = ShowQueryDetailRequest()
request.cluster_id = "{cluster_id}"
request.query_id = "{query_id}"
response = client.show_query_detail(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region"
)
func main() {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak := os.Getenv("CLOUD_SDK_AK")
sk := os.Getenv("CLOUD_SDK_SK")
projectId := "{project_id}"
auth := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
WithProjectId(projectId).
Build()
client := dws.NewDwsClient(
dws.DwsClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.ShowQueryDetailRequest{}
request.ClusterId = "{cluster_id}"
request.QueryId = "{query_id}"
response, err := client.ShowQueryDetail(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
package com.huaweicloud.sdk.test;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.auth.BasicCredentials;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.dws.v2.region.DwsRegion;
import com.huaweicloud.sdk.dws.v2.*;
import com.huaweicloud.sdk.dws.v2.model.*;
public class ShowQueryDetailSolution {
public static void main(String[] args) {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
String ak = System.getenv("CLOUD_SDK_AK");
String sk = System.getenv("CLOUD_SDK_SK");
String projectId = "{project_id}";
ICredential auth = new BasicCredentials()
.withProjectId(projectId)
.withAk(ak)
.withSk(sk);
DwsClient client = DwsClient.newBuilder()
.withCredential(auth)
.withRegion(DwsRegion.valueOf("<YOUR REGION>"))
.build();
ShowQueryDetailRequest request = new ShowQueryDetailRequest();
request.withClusterId("{cluster_id}");
request.withQueryId("{query_id}");
try {
ShowQueryDetailResponse response = client.showQueryDetail(request);
System.out.println(response.toString());
} catch (ConnectionException e) {
e.printStackTrace();
} catch (RequestTimeoutException e) {
e.printStackTrace();
} catch (ServiceResponseException e) {
e.printStackTrace();
System.out.println(e.getHttpStatusCode());
System.out.println(e.getRequestId());
System.out.println(e.getErrorCode());
System.out.println(e.getErrorMsg());
}
}
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# coding: utf-8
import os
from huaweicloudsdkcore.auth.credentials import BasicCredentials
from huaweicloudsdkdws.v2.region.dws_region import DwsRegion
from huaweicloudsdkcore.exceptions import exceptions
from huaweicloudsdkdws.v2 import *
if __name__ == "__main__":
# The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
# In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak = os.environ["CLOUD_SDK_AK"]
sk = os.environ["CLOUD_SDK_SK"]
projectId = "{project_id}"
credentials = BasicCredentials(ak, sk, projectId)
client = DwsClient.new_builder() \
.with_credentials(credentials) \
.with_region(DwsRegion.value_of("<YOUR REGION>")) \
.build()
try:
request = ShowQueryDetailRequest()
request.cluster_id = "{cluster_id}"
request.query_id = "{query_id}"
response = client.show_query_detail(request)
print(response)
except exceptions.ClientRequestException as e:
print(e.status_code)
print(e.request_id)
print(e.error_code)
print(e.error_msg)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
package main
import (
"fmt"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/core/auth/basic"
dws "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2"
"github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/model"
region "github.com/huaweicloud/huaweicloud-sdk-go-v3/services/dws/v2/region"
)
func main() {
// The AK and SK used for authentication are hard-coded or stored in plaintext, which has great security risks. It is recommended that the AK and SK be stored in ciphertext in configuration files or environment variables and decrypted during use to ensure security.
// In this example, AK and SK are stored in environment variables for authentication. Before running this example, set environment variables CLOUD_SDK_AK and CLOUD_SDK_SK in the local environment
ak := os.Getenv("CLOUD_SDK_AK")
sk := os.Getenv("CLOUD_SDK_SK")
projectId := "{project_id}"
auth := basic.NewCredentialsBuilder().
WithAk(ak).
WithSk(sk).
WithProjectId(projectId).
Build()
client := dws.NewDwsClient(
dws.DwsClientBuilder().
WithRegion(region.ValueOf("<YOUR REGION>")).
WithCredential(auth).
Build())
request := &model.ShowQueryDetailRequest{}
request.ClusterId = "{cluster_id}"
request.QueryId = "{query_id}"
response, err := client.ShowQueryDetail(request)
if err == nil {
fmt.Printf("%+v\n", response)
} else {
fmt.Println(err)
}
}
|
更多编程语言的SDK代码示例,请参见API Explorer的代码示例页签,可生成自动对应的SDK代码示例。
状态码
状态码 |
描述 |
---|---|
200 |
查询成功。 |
400 |
请求错误。 |
401 |
鉴权失败。 |
403 |
没有操作权限。 |
404 |
找不到资源。 |
500 |
服务内部错误。 |
503 |
服务不可用。 |