Understand why the index can quickly find data

A brief overview:

  When we store data, if the index. Database system maintains a data structure to meet specific search algorithm, these data structures referenced data in some way
  can be on top of these data structures, implement advanced search algorithm, this structure is the index
  in general, the index itself is also great, It can not in memory, so often in the form of an index index files are stored on disk storage of all
  physical addresses in order to speed up the finding data, can maintain a binary search tree, each node and each comprising a key index pointing to the corresponding data record pointer,
  so you can use a binary search to obtain the corresponding data in a certain complexity to quickly retrieve the qualifying record
  in addition to index binary tree there BTtree I usually say the index, if not specified, are B refers to the index tree structure of the tissue
  where the focus index, secondary index, a composite index, prefix index, the default is the only addition to the B + tree index B + tree index, and a hash index (hash index) like
binary search tree:

  Features: If the left subtree of any node is not empty, then the value of the left sub-tree, all the nodes are less than the value of the root;
         right subtree of any node is not empty, the right subtree of all nodes values were greater than the value of the root;
         left any node, respectively for the right subtree binary search tree.
         No equivalent key nodes (no duplicate nodes)

  Graphic presentation:

     

  Analysis: The use of this method can help us quickly locate the data lookup, to find if the data is 52, the first step we start from the root 37, found larger than 38, 50 to the right to find, and then find

        More than 50 large, to the right of the search, you can find three position. But this is not the best method to find the data if we look only at one side of the display, the search speed is very slow

B-Tree balanced multi-way search tree:

  Features: m-order B-Tree meet the following criteria: 

     0. root comprises at least two children red for key
       1. Each node in the tree children up to m (m> = 2)
       2. In addition to the root node and leaf nodes, each other node having at least Ceil (m / 2) children.
       3. All leaf nodes are in the same layer
       4. ki (1 = 1 ... n ) as a keyword, and the keywords are arranged in ascending order k (i-1) <k 8 <9 ( the number of red is left of the keyword smaller than the right)

       5. The number n satisfies keyword: ceil (m / 2) -1 <= n <= m-1 (non-leaf node key number is less than a pointer pointing to a child)

       6. The non-leaf node pointer p [1], p [2], ... p [m] wherein p1 pointing key is smaller than k [1] subtrees 3 <8

           p [m] key is larger than the pointer k [m-1] subtree 15> 12 is
           P [I] keywords belong point (k [i-1], k [i]) is the sub-tree located 8 9,10 and between 12

     Icon:

    

      




 

 

Guess you like

Origin www.cnblogs.com/pcliu/p/11101403.html