该语句用于解释 SQL 语句的执行计划,可以是 SELECT
、DELETE
、INSERT
、REPLACE
或 UPDATE
语句。
获取表或列的信息:
{EXPLAIN | DESCRIBE | DESC} tbl_name [col_name | wild]
获取SQL计划信息:
{EXPLAIN}
[BASIC | OUTLINE | EXTENDED | EXTENDED_NOADDR | PARTITIONS | FORMAT = {TRADITIONAL| JSON}]
{SELECT statement | DELETE statement | INSERT statement | UPDATE statement | MERGE statement}
参数 |
描述 |
---|---|
tbl_name |
指定表名。 |
col_name |
指定表的列名。 |
BASIC |
指定输出计划的基础信息,如算子 ID、算子名称、所引用的表名。 |
OUTLINE |
指定输出的计划信息包含 Outline 信息。 |
EXTENDED |
|
EXTENDED_NOADDR |
以简约的方式展示附加信息。 |
PARTITIONS |
显示分区相关信息。 |
FORMAT = {TRADITIONAL| JSON} |
指定
|
explain_type
obclient>CREATE TABLE t1(c1 INT,c2 INT);
Query OK, 0 rows affected (0.04 sec)
obclient>CREATE TABLE t2(c1 INT,c2 INT);
Query OK, 0 rows affected (0.07 sec)
obclient>EXPLAIN SELECT * FROM t1,t2 WHERE t1.c2=t2.c2 AND t2.c1 > 4G
*************************** 1. row ***************************
Query Plan: =======================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
---------------------------------------
|0 |HASH JOIN | |9801000 |5933109|
|1 | TABLE SCAN|t2 |10000 |6219 |
|2 | TABLE SCAN|t1 |100000 |68478 |
=======================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t2.c1], [t2.c2]), filter(nil),
equal_conds([t1.c2 = t2.c2]), other_conds(nil)
1 - output([t2.c2], [t2.c1]), filter(nil),
access([t2.c2], [t2.c1]), partitions(p0)
2 - output([t1.c2], [t1.c1]), filter(nil),
access([t1.c2], [t1.c1]), partitions(p0)
obclient>EXPLAIN EXTENDED_NOADDR SELECT * FROM t1,t2
WHERE t1.c2=t2.c2 AND t2.c1 > 4G
*************************** 1. row ***************************
Query Plan: =======================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
---------------------------------------
|0 |HASH JOIN | |9801000 |5933109|
|1 | TABLE SCAN|t2 |10000 |6219 |
|2 | TABLE SCAN|t1 |100000 |68478 |
=======================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t2.c1], [t2.c2]), filter(nil),
equal_conds([t1.c2 = t2.c2]), other_conds(nil)
1 - output([t2.c2], [t2.c1]), filter(nil),
access([t2.c2], [t2.c1]), partitions(p0),
is_index_back=false,
range_key([t2.c1]), range(4 ; MAX),
range_cond([t2.c1 > 4])
2 - output([t1.c2], [t1.c1]), filter(nil),
access([t1.c2], [t1.c1]), partitions(p0),
is_index_back=false,
range_key([t1.__pk_increment], [t1.__pk_cluster_id], [t1.__pk_partition_id]), range(MIN,MIN,MIN ; MAX,MAX,MAX)always true
TRADITIONAL
格式obclient>EXPLAIN FORMAT=TRADITIONAL SELECT * FROM t1,t2
WHERE t1.c2=t2.c2 AND t2.c1 > 4G
*************************** 1. row ***************************
Query Plan: =======================================
|ID|OPERATOR |NAME|EST. ROWS|COST |
---------------------------------------
|0 |HASH JOIN | |9801000 |5933109|
|1 | TABLE SCAN|t2 |10000 |6219 |
|2 | TABLE SCAN|t1 |100000 |68478 |
=======================================
Outputs & filters:
-------------------------------------
0 - output([t1.c1], [t1.c2], [t2.c1], [t2.c2]), filter(nil),
equal_conds([t1.c2 = t2.c2]), other_conds(nil)
1 - output([t2.c2], [t2.c1]), filter(nil),
access([t2.c2], [t2.c1]), partitions(p0)
2 - output([t1.c2], [t1.c1]), filter(nil),
access([t1.c2], [t1.c1]), partitions(p0)
obclient>EXPLAIN FORMAT=JSON SELECT * FROM t1,t2
WHERE t1.c2=t2.c2 AND t2.c1 > 4G
*************************** 1. row ***************************
Query Plan: {
"ID":2,
"OPERATOR":"JOIN",
"NAME":"JOIN",
"EST.ROWS":9800999,
"COST":6840524,
"output": [
"T1.C1",
"T1.C2",
"T2.C1",
"T2.C2"
],
"CHILD_1": {
"ID":0,
"OPERATOR":"TABLE SCAN",
"NAME":"TABLE SCAN",
"EST.ROWS":10000,
"COST":80810,
"output": [
"T2.C2",
"T2.C1"
]
},
"CHILD_2": {
"ID":1,
"OPERATOR":"TABLE SCAN",
"NAME":"TABLE SCAN",
"EST.ROWS":100000,
"COST":64065,
"output": [
"T1.C2",
"T1.C1"
]
}
}
1 row in set (0.01 sec)
EXPLAIN 的每个输出行提供一个表的相关信息,并且每个行包括下面的列:
列名 |
说明 |
---|---|
ID |
计划执行序列号。 |
OPERATOR |
执行算子。 |
NAME |
算子所引用的表。 |
EST.ROWS |
估计执行到当前算子输出的行数。 |
COST |
执行到当前算子的 CPU 时间。 |
Readablepublic interface ReadableReadable 是字符的来源。 来自 Readable 的字符可通过 CharBuffer 提供给 read 方法的调用者...
StringBuilderjava.lang.Object |---java.lang.StringBuilderpublic final class StringBuilderextends Objectimplements Append...
UnknownErrorjava.lang.Object |---java.lang.Throwable |---|---java.lang.Error |---|---|---java.lang.VirtualMachineError |...
Object wx小程序 API 全局对象,用于承载小程序能力相关 API。Object wx.env小程序环境变量对象String wx.env.USER_DATA_PATH文...
商品数据接入(内测)商品数据应用场景商品数据目前应用于微信扫一扫识物功能、小程序商品搜索功能和扫条码三个功能。 这些功能...
operation.getFeedback本接口应在服务器端调用,详细说明参见服务端API。获取用户反馈列表请求地址GET https://api.weixin.qq.co...
错误码在使用云能力时抛出的异常(fail 回调 / Promise reject)Error对象中会带有errCode和errMsg,云开发 HTTP API 回包中也会...