MySQL Execution analysis

Source: Internet
Author: User

Select_type: represents the type of select, the following are common

Simple table, which does not use a connection or subquery

PRIMARY: main query, which is the outer query

UNION: The second or subsequent query statement in a union

subquery: The first select in a subquery

Table : tables for output result sets

Type : represents the connection type for the table, with the following sequence of performance from good to Bad

System: There is only one row in the table, which is the constant table

Const: There is a maximum of one matching row in a single table, such as primary key or unique index

eq_ref: for each preceding row, only one record is queried in this table, that is, primary key or unique index is used in a multi-table connection

ref: Similar to Eq_ref, the difference is that instead of using primary key or unique index, you use a normal index

Ref_or_null: with ref type, except that the condition contains a null query

index_merge: Index Consolidation optimization

unique_subquery: in is followed by a subquery that queries the primary key field

index_subquery: similar to Unique_subquery, except that in is followed by subqueries that query for non-unique indexed fields

Range : scope query in a single table

Index : for each preceding row, the data is obtained by querying the index

All : for each previous row, the data is scanned by the full table

Possible_keys: indexes that may be used when querying

key: The index that was actually used when querying

Key-len: Length of index field

rows: number of scanned rows

Extra: Description and description of the implementation

For example:

EXPLAIN SELECT SUM (money) from sales S,company C WHERE s.company_id=c.id and s.year=2006 \g;

1. Row ***************************
Id:1
Select_type:simple
Table:s
Type:ref
Possible_keys:index_seles_year
Key:index_sales_year
Key_len:2
Ref:const
Rows:1
Extra:using where

2. Row ***************************
Id:1
Select_type:simple
Table:c
Type:ref
possible_keys:index_company_id
key:index_company_id
Key_len:5
ref:sakila.c.company_id
Rows:1
Extra:using where; Using Index

MySQL Execution analysis

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.