mysql explain explain (part of the index)

Index Search becomes faster, but additions and deletions will be slow

The index itself should occupy the space

* .Myini presence of

Introduce a tool

Explain 

This is an analysis tool that can analyze a sql statement, sql statement execution efficiency can be predicted.

mysql> explain select * from emp where empno= 998776\G;

*************************** 1. row ***************************

 

           id: 1 // representatives of the index value of the sql statement used

  select_type: SIMPLE // simple, ordinary index

        table: emp // now is what query tables, multi-table multi-table will be displayed

   partitions: NULL

         type: const // link type constant table, there are three kinds,

possible_keys: PRIMARY // might use index

          key: PRIMARY // actual use of the index

      key_len: 3 // index length

          ref: const

         rows: 1 // how much is taken out from the line in the

     filtered: 100.00 // return means results need to scan the row per row (value row rows) Percentage

        Extra: NULL

1 row in set, 1 warning (0.00 sec)

 

ERROR: 

No query specified

 

sql statement add \ G may be longitudinally aligned

Type There are three kinds: all represents a full table scan is very slow, plus an index, so as const

Table system only one row (= system table), which is a type of link to match const

Const represents at most one match

possible_keys would choose an optimal index

 

Delete Index

Alter table drop PRIMARY KEY(字段);

If the primary key, an index is automatically

This statement is an analysis will not use the index, what is the description of the way, but the analysis is not out of time.

 

Extra Query details

No tables, no table query

Using filesort This is the sort files, to try to avoid, is very slow.

Using temporary certain operations must use a temporary table

Common group by order by 

Using where all the information in the table do not read, you can get information only through the index

 

According to explain information, we can see that, sql statement whether the use of the index, how much is taken out of the record, you can also see sort of way.

 

But if such a query:

select * from emp where  ename='ouiHJB';

Or become very slow, because there is no indexed.

 

Guess you like

Origin www.cnblogs.com/ayanboke/p/10983175.html