Index works and optimize MySQL / MariaDB database

     Index works and optimize MySQL / MariaDB database

                            Author: Yin Zhengjie 

Copyright: original works, declined to reprint! Otherwise held liable.

 

  Practical work index this technology is a very important indicator affecting server performance, so we have to take the time to look at the relevant characteristics of the index.

 

I. Overview Index

1> What is the index

  Index is a special data structure is defined as a search criteria when looking for a field, also known as key in MySQL key, the index achieved by the storage engine. 

  With the performance of the index does not mean that we will be able tips, with the index we have to take advantage of the index, the index in the right way, improper use can actually reduce server performance.

Advantage 2>. Index

  Indexes can reduce the amount of data services need to scan, reducing the number of IO
 
  index servers can help avoid sorts, and use of temporary table
  index can help random the I
/ O into the order of the I / O

Shortcomings 3> index

  Taking up extra space, affecting the speed of insertion

 

II. Index Type

  B + the TREE, the HASH, the TREE R & lt 

  clusters (sets) index, non-clustered index: 
    data and index is stored together with   the primary key index, two (secondary) index   dense index, sparse index:
    whether each data item indexed   simple index, composite index:     left prefix index: take the preceding character indexed     cover index: the data to be queried can be removed from the index, high performance

1>. Binary tree

  

 

( 1 ) a maximum of two per node subtree 
    binary absence of degree greater than 2 nodes. 

( 2 ) it is an ordered tree, left subtree, right subtree is the order, the order can not be exchanged 

( 3 ) Even if a tree node has only one child, but also make sure it is still left subtree right subtree 

( 4 ) the basic form of the binary tree species
    1 ) empty binary
    2 ) only one root
    3 ) only the left sub-tree root node
    4 ) only the right subtree root
    5 ) with a left subtree root and the right subtree 

bloggers recommended read: 
  HTTPS: // baike.baidu.com / Item /% E4 % BA % . 8C % E5 % 8F % 89 % E6 % A0 % 91
  https://www.cnblogs.com/yinzhengjie/p/10960896.html

2>. Red-black tree (also known as self-balancing binary tree)

 

 

 

Bloggers Recommended reading: 
  HTTPS: // baike.baidu.com / Item /% E7 % BA % A2 % E9 % BB % 91 % E6 % A0 % 91

 

3> .B-tree index (B-tree (multipath search tree is not binary) of

B - Tree (multiple search tree, not a binary) is a common data structure. Use B - Tree structure may be significantly reduced when the process intermediate location history experienced, thus speeding up the access speed. According to the translation, B Balance is usually considered to be short. This data structure is generally used index database, higher overall efficiency. 

Bloggers Recommended reading: 
  HTTPS: // baike.baidu.com / Item / B - Tree / 6606402 fr? = Aladdin

 

4> .B + tree

B + tree is a tree data structure, typically the database and operating system's file system. B + characteristic data tree is able to maintain stable and orderly, which has a more stable insertion and modification time complexity of the number of pairs. B + tree element is inserted from the bottom up, which is just the opposite binary tree. 

Bloggers Recommended reading: 
  HTTPS: // baike.baidu.com / Item / B +% E6 % A0 % 91 / 7,845,683

 

5> .Hash Index

 

6>.

 

7>.

 

8>.

 

 

three.

 

four.

 

Fives.

 

Guess you like

Origin www.cnblogs.com/yinzhengjie/p/11762653.html