Relationship of conditional query plus sort and index in MySQL

Source: Internet
Author: User
Tags mysql in

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.