explain select * from test2 where code = '001'; 1. 结果: range 常用于范围查询,比如:between ... and 或 In 等操作,执行sql如下: explain select * from test2 where id between 1 and 2; 1. 结果: index 全索引扫描。执行sql如下: explain select code from test2; 1. 结果: ALL 全表扫描。执...
select_type列常见的有: simple:表示不需要union操作或者不包含子查询的简单select查询。有连接查询时,外层的查询为simple,且只有一个 primary:一个需要union操作或者含有子查询的select,位于最外层的单位查询的select_type即为primary。 且只有一个 union:union连接的两个select查询,第一个查询是dervied派生表,除了第...
{explainable_stmt | FOR CONNECTION connection_id} {EXPLAIN | DESCRIBE | DESC} ANALYZE select_statement explain_type: { FORMAT = format_name } format_name: { TRADITIONAL | JSON | TREE explainable_stmt: { SELECT statement | TABLE statement | DELETE statement | INSERT statement | REPLACE stat...
The SELECT identifier. This is the sequential number of the SELECT within the query. The value can be NULL if the row refers to the union result of other rows. In this case, the table column shows a value like <unionM,N> to indicate that the row refers to the union of the rows wi...
explain可用来分析SQL的执行计划。格式如下: {EXPLAIN|DESCRIBE|DESC} tbl_name [col_name|wild] {EXPLAIN|DESCRIBE|DESC} [explain_type] {explainable_stmt|FORCONNECTION connection_id} {EXPLAIN|DESCRIBE|DESC} ANALYZE select_statement explain_type: { ...
SelectStatement|||IMCI Execution Plan (max_dop=4, max_query_mem=858993459)||2|└─Sort|||Sort Key: revenueDESC,o_orderdateASC||3|└─Hash Groupby|||GroupKey: (lineitem.L_ORDERKEY, orders.O_ORDERDATE, orders.O_SHIPPRIORITY)||4|└─HashJoin|||JoinCond: orders.O_ORDERKEY=lineitem.L...
log_queries_not_using_indexs<==没有走索引的语句,记录到 log 里 log-slow-queries = /data/3306/slow.log 18.3 对抓取到的慢查询语句用 explain 命令检查索引执行情况 例如: explain select *fromtest where name=’oldboy’\G; 18.4 对需要建索引的条件列建立索引 ...
该语句用于解释 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}]{SELECTstatement|DELETEstatement|INSERTstatement...
EXPLAIN SELECT*FROM customer WHERE active=0; 2.type=index,索引全扫描,MySQL遍历整个索引来查询匹配行,并不会扫描表 一般是查询的字段都有索引的查询语句 EXPLAIN SELECT store_id FROM customer; 3.type=range,索引范围扫描,常用于<、<=、>、>=、between等操作 ...
EXPLAIN works with SELECT, DELETE, INSERT, REPLACE, and UPDATE statements. EXPLAIN与SELECT、DELETE、INSERT、REPLACE和UPDATE语句一起工作。 When EXPLAIN is used with an explainable statement, MySQL displays information from the optimizer about the statement execution plan. That is, MySQL explains how it...