To query the SELECT query statement execution plan using explain

Source: Internet
Author: User

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

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.