Explain MySQL Query statement _ MySQL

Source: Internet
Author: User
Explainmysql query statement MySQLexplain

BitsCN.com

Explain mysql Query statement

Description:

SQL code

Mysql> explain SELECT 'content _ id', 'content _ old_id ', 'content _ hasimg', 'content _ time_update ', 'content _ title_long', 'vhost _ content '. 'site _ id', 'site _ domain ', 'site _ name ', 'site _ state' FROM 'vhost _ content' left join 'vhost _ site' ON 'vhost _ content '. 'site _ id' = 'vhost _ site '. 'site _ id' WHERE 'content _ effect '= 1 AND 'content _ audit' = 1 AND 'content _ publish' = 1 AND 'content _ time_update '> = '2017- 12-16 'AND 'vhost _ content '. 'site _ id' LIKE '200' AND 1 = 1 order by 'content _ time_update 'desc LIMIT 0, 25;

+ ---- + ------------- + --------------- + ------- + Response + ------------------ + --------- + ----------------------------- + ------ + ------------------------------- +

| Id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |

+ ---- + ------------- + --------------- + ------- + Response + ------------------ + --------- + ----------------------------- + ------ + ------------------------------- +

| 1 | SIMPLE | vhost_content | range | idx_content_site, Refvhost_site483, idx_content_uptime, idx_content_publish | idx_content_site | 55 | NULL | 198 | Using where; Using filesort |

| 1 | SIMPLE | vhost_site | ref | PRIMARY | 54 | vhostdb. vhost_content.site_id | 1 |

+ ---- + ------------- + --------------- + ------- + Response + ------------------ + --------- + ----------------------------- + ------ + ------------------------------- +

Table: displays the database tables involved in the statement.

Type: This column is very important and shows the category used by the connection, whether or not indexes are used, and the statement quality. The result values are: system> const> eq_ref> ref> fulltext> ref_or_null> index_merge> unique_subquery> index_subquery> range> index> ALL. generally, make sure that the query reaches the range level at least. it is best to reach the ref level; otherwise, performance problems may occur.

Possible_key: indicates which index mysql can use to find rows in the table.

Key: displays the keys (Indexes) actually used by mysql. If no index is selected, the Key is null.

Key_len: displays the key length determined by mysql. If it is null, the length is null. the shorter the length, the better, without compromising accuracy.

Ref: displays the column or constant used with the key to select rows from the table.

Rows: displays the number of Rows that mysql considers to be checked when performing a query.

Extra: contains detailed information about mysql queries.

BitsCN.com

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.