With a friend, a good company supervisor. When communicating with the index in MySQL in conditional query and sort
Mysql> Explain select * from article where title= ' Hope PV Enterprise survived 2 months ' O
Rder by ID desc\\\\\\\\g
1. Row ***************************
Id:1
Select_type:simple
Table:article
Type:index
Possible_keys:null
Key:primary
Key_len:4
Ref:null
rows:567
Extra:using where
1 row in Set (0.00 sec)
Mysql> SELECT * from article where title= ' Hope PV Enterprise survived 2 months ';
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
| ID | category_id | user_id | app_id | Title | Subtitle |
Professor | Money | Cooperation | Project | Address | Discription
| SOURCE | R
Ecommend | Status | CTime | Mtime |
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
| 10 | 2 | 4 | 0 | Hope PV Enterprise survived 2 months | |
| 0 | | | | Hope the enterprise survived two months. | |
1 | 0 | 1371524848 | 1371525226 |
+----+-------------+---------+--------+-----------------------------+----------+
-----------+-------+-------------+---------+---------+--------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------+--------+--
---------+--------+------------+------------+
1 row in Set (0.00 sec)
Mysql> Explain select * from article where title= ' Hope PV Enterprise survived 2 months ';
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
| ID | Select_type | Table | Type | Possible_keys | Key | Key_len | Ref | Ro
WS | Extra |
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
| 1 | Simple | Article | All | NULL | NULL | NULL | NULL | 5
67 | Using where |
+----+-------------+---------+------+---------------+------+---------+------+---
---+-------------+
1 row in Set (0.00 sec)
Developers in the big department would think that the first query would not use the index
This article is from the Linux OPS blog, so be sure to keep this source http://2853725.blog.51cto.com/2843725/1562343
Relationship of conditional query plus sort and index in MySQL