1. Query the SELECT query statement execution plan using explain
Mysql> select * from baba where name = ' FJDSJF ';
+------+--------+
| ID | name |
+------+--------+
| 1 | FJDSJF |
+------+--------+
Query the execution plan for the SQL statement
Mysql> Explain select * from baba where name = ' FJDSJF ' \g;
1. Row ***************************
Id:1
Select_type:simple
Table:baba
Type:all
Possible_keys:null
Key:null
Key_len:null
Ref:null
Rows:2
Extra:using where
1 row in Set (0.00 sec)//The SQL statement does not go index
To increase the index:
Mysql> CREATE index Index_baba on baba (name);
Query OK, 2 rows affected (0.09 sec)
Records:2 duplicates:0 warnings:0
mysql> desc Baba;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| ID | Int (11) | YES | | NULL | |
| name | varchar (30) | YES | MUL | NULL | |
+-------+-------------+------+-----+---------+-------+
Mysql> Explain select * from baba where name = ' FJDSJF ' \g;
1. Row ***************************
Id:1
Select_type:simple
Table:baba
Type:ref
Possible_keys:index_baba
Key:index_baba
Key_len:33
Ref:const
Rows:1//Search for a row and find the
Extra:using where
2. Learn to use the implementation plan to help
Mysql> help explain
Name: ' EXPLAIN '
Description:
Syntax:
EXPLAIN [Explain_type] SELECT select_options
Explain_type:
EXTENDED
| Partitions
Or:
EXPLAIN Tbl_name
The EXPLAIN statement can be used either as a-to obtain information
about what MySQL executes a statement, or as a synonym for DESCRIBE:
o When you precede a SELECT statement with the keyword EXPLAIN, MySQL
Displays information from the optimizer about the query execution
Plan. That's, MySQL explains how it would process the statement,
Including information about how tables is joined and in which order.
EXPLAIN EXTENDED can is used to obtain additional information.
For information about using EXPLAIN and EXPLAIN EXTENDED to obtain
Query execution plan information, see
Http://dev.mysql.com/doc/refman/5.1/en/using-explain.html.
This article from the "Technology in hand, the world I have" blog, please be sure to keep this source http://xin521long.blog.51cto.com/11884590/1882496
To query the SELECT query statement execution plan using explain