MySQL中一些关于索引的知识点
- 2019 年 10 月 3 日
- 笔记
?????
????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????????????????????????
????
???????????????????????????MySQL?????Hash???B+Tree?
Hash??
hash???????????hash???key-value???????????????+????????hash?????key??????????????hash??????????(???)??????????hash??????hash????????????????????HashMap?????????????????
hash???????????key?hash??????????????????????????????????????????
- ??????????key???????????????????????????????
- hash???????????hash????????????????????hash??????????????(??????????????????)
- hash?????????????hash???????key?????????????key?????like??????????????
??????????hash????????????????
B+Tree??
???????????????????????????????????????????????????????????????
??????hash???????????????????????????????–???????????????????????????????????????????
????????????????O(log(n))??????O(log(n))?????????????????????
??MySQL?????????????????????????????????????????????????????????????????????????????MySQL???????????????????????????????????????????????????????????????????B+Tree??B+Tree???????????????????????????????
B-Tree
???B+Tree??????B-Tree?B-Tree??????????B???Balance???Binary??????B-Tree???????????
???????????
????2-3??????????????????????????3???????????????????????????????????????????????????????????????????????????????????????
???????24????
- ????????24????(15,25)??????????????????
- ????????????(18,22)?????24????????????????????
- ????????????????24?????
???????????B?????
- ????????????????????????????
- ??????????????????????????
- ?????????????????????????????
??????????????????????????????????B-Tree?????????????????B-Tree?????????????????????????????MySQL???????????????????????????(??16k)?????????????????????????????????????????????????????????????
B+Tree
B+Tree??B-Tree????????????????????????
????????????B-Tree???????????????B+Tree???????????????????????????????????????????????????????????????????????????????????????????
??
??????????????????????????MySQL?InnoDB???
????
????????????????????????????????????????????????????InnoDB????????????????????????????InnoDB ??????????????????????????????????InnoDB????????????????(row_id)?
?????????
???????
?InnoDB???????????????????????????????????????????????????????????????????
??????????
?????????????????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????
????
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
???????????????????????????????????????????????????????????(???????)????????????????????????????????????????????
?????????????????????????????????????????????????????????????????
??????????????????????????index(a,b)??a?b?????????????????????ab????????????????b????????????????????????????????????????????
??????
????????index(a,b)???????a?b???????????????a????????????????????b??????????????????????????????????????n?????????????????
???????????????????????????????????
????????????????????????????????????????????????????????????????????
????????????????????????????????????????????????(??????????????????????????????????????????n??????????????n???)?
??index(a,b)?????????????????a????????????????????????????????
????????????????????????????????????????????????????????????????????????????
??????????????????????????????????????
????
MySQL?????MySQL?Galera?Inception?????????