MySQL Index Analysis

  Read many articles on the Internet index, also known almost watching a lot, or is too simple, not very well understood; or is too complicated, do not know what you want to express it so I decided to pro. blog to write again on the index, if wrong, please correct me criticism, thank you.

  A. First, we need to be clear what is the first index is a concept.

  For a MySQL DBA, the desired query data in a MySQL database and then view or modify it, so we have to repeat things every day. Since we do MySQL DBA or doing work related to the MySQL database, then I believe fraction is concerned, we should all have extremely demanding requirements. in fact, this is also the reason we want to create a primary key and indexes, because in my opinion I can not wait to look at the data, it can give me a few lines I find a few OK, that query efficiency of 100%.

  II. To index it under what circumstances?

  Prior to solve this problem I would like to attract to talk about the primary key is well known compared to let sql statement index up to find when we perform more willing to let it go on the primary key, the efficiency of such I think is the highest, so the index is often in we are a data regularly to find, but the basis of this column are not built up the primary key.

  III. Then the index so easy why not create an index on several columns it?

  1. The index is up space, we now have higher performance requirements for the database, we ought to consider the use of space

  Confusion such as it is to this column data you create sort after you change the time in an already well-established in the implementation of the index table insert or update, we know the index 2. When the index is likely to cause too much fast data query , so when one day after the execution of the statement because he might have to give him more indexes sort of memory caused by an increase in abuse and IO (index ordering is done in the memory space, the occurrence of physical read, so the index table inside the more, the impact will clear up).

  3. Create a full table scan index will take place, in general, once you start running on-line database, and we look forward to him is, until the end of the product life cycle database can not fault has occurred, so it is clear that if random in a table index on multiple columns, most likely occurred because the database full table scan and sort live even cause a fatal impact on database Kang.

  IV. Adaptive hash index

  1. What is the adaptive hash index it?

  When we created the index is accessed frequently used in the database, this will become a secondary index heat index, as innodb_buffer_pool thermal data as this time hash index will be triggered, the index into the hash index inside, when generating the index into the hash index to the inside after, according to the index is no longer a high-level tree searched, but directly according to find conditions where the corresponding sql statement.

  advantage:

    1. There is no tree height

    2. Find the faster, more accurate

    3. Under extreme circumstances, can reduce the significance of the comparison is logical reads

  Disadvantages:

    1. not able to find the range, only to find the exact one to one.

    2. take up innodb_buffer_pool in memory (linux system, everything is a file, so the index is a file .index table stored on disk, so the caller is calling a file index, it will take up memory)

  Welcome to correct me Comments

    Author:

      email:[email protected]

      QQ:1318416578     

 

Guess you like

Origin www.cnblogs.com/mxk131/p/11089805.html