MySQL資料庫中索引原理與資料結構,mysql索引

來源:互聯網
上載者:User

MySQL資料庫中索引原理與資料結構,mysql索引

MySQL中的索引分為3種:

1,主鍵索引:即用主鍵當唯一索引

2,常規索引:實現方式為B樹和雜湊表

3,全文索引:實現原理類似倒排索引,常用來查詢欄位中包含關鍵字

下面複習下B-TREE和hash-table


1 B-tree

B樹可以在O(lgn)的時間內實現許多動態集合操作,除了用在資料庫索引上,也被用在磁碟尋找上。

B樹是一種多路尋找平衡多叉樹,具有以下屬性:


1,如果根節點不是分葉節點,則其至少有兩棵子樹。

2、每個非根節點所包含的關鍵字個數 j 滿足:┌m/2┐ - 1 <= j <= m - 1;

 3、除根結點以外的所有結點(不包括葉子結點)的度數正好是關鍵字總數加1,故內部子樹個數 k 滿足:┌m/2┐ <= k <= m ; 

4、所有的葉子結點都位於同一層。

每個節點中的元素從小到大排序


相關文章

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.