Skip to content

Commit

Permalink
update residual
Browse files Browse the repository at this point in the history
  • Loading branch information
wolverinn committed Dec 21, 2019
1 parent 18e68cd commit 13b5810
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
28 changes: 20 additions & 8 deletions Database.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [Drop/Delete/Truncate的区别?](#DropDeleteTruncate的区别)
* [什么是视图?什么是游标?](#什么是视图什么是游标)
* MySQL
* [数据库索引的实现原理(B+树)](#数据库索引的实现原理B-树)
* [使用索引的优点](#使用索引的优点)
* [哪些情况下索引会失效?](#哪些情况下索引会失效)
* [在哪些地方适合创建索引?](#在哪些地方适合创建索引)
Expand Down Expand Up @@ -201,6 +202,24 @@ delete;
- **简化**复杂的SQL操作,隐藏数据的复杂性(比如复杂的连接);
- 游标(Cursor):用于定位在查询返回的**结果集的特定行**,以对特定行进行操作。使用游标可以方便地对结果集进行移动遍历,根据需要滚动或对浏览/修改任意行中的数据。主要用于交互式应用。

------

### 数据库索引的实现原理(B+树)

见数据结构部分:B树,B+树

##### 使用B树和B+树的比较

InnoDB的索引使用的是B+树实现,B+树对比B树的好处:

- IO次数少:B+树的中间结点只存放索引,数据都存在叶结点中,因此中间结点可以存更多的数据,让索引树更加矮胖;
- 范围查询效率更高:B树需要中序遍历整个树,只B+树需要遍历叶结点中的链表;
- 查询效率更加稳定:每次查询都需要从根结点到叶结点,路径长度相同,所以每次查询的效率都差不多

##### 使用B树索引和哈希索引的比较

哈希索引能以 O(1) 时间进行查找,但是只支持精确查找,无法用于部分查找和范围查找,无法用于排序与分组;B树索引支持大于小于等于查找,范围查找。哈希索引遇到大量哈希值相等的情况后查找效率会降低。哈希索引不支持数据的排序。

### 使用索引的优点
- 大大加快了数据的**检索速度**
- 可以显著减少查询中**分组和排序**的时间;
Expand All @@ -217,7 +236,6 @@ delete;
- 如果MySQL估计全表扫描比索引快,则不使用索引(比如非常小的表)

### 在哪些地方适合创建索引?
- WHERE子句或连接条件经常引用的列;
- 某列经常作为最大最小值;
- 经常被查询的字段;
- 经常用作表连接的字段;
Expand Down Expand Up @@ -353,10 +371,4 @@ delete;
- [Redis面试题总结 - 简书](https://www.jianshu.com/p/65765dd10671)
- [Redis常见面试题 - 博客园](https://www.cnblogs.com/jasontec/p/9699242.html)
- [0voice/interview_internal_reference](https://github.com/0voice/interview_internal_reference#10)
- [ ] [史上最全的数据库面试题,不看绝对后悔 -- 博客园](https://www.cnblogs.com/wenxiaofei/p/9853682.html)
- [ ] MySQL索引的底层实现原理(B+ Tree)(https://blog.csdn.net/justloveyou_/article/details/78308460)
- [ ] 使用B+ 与红黑树、B-、Hash索引的比较(https://github.com/CyC2018/CS-Notes/blob/master/notes/MySQL.md)

![1](_v_images/20191208114637992_16460.jpg)

![2](_v_images/20191208114719944_27728.jpg)
- [ ] [史上最全的数据库面试题,不看绝对后悔 -- 博客园](https://www.cnblogs.com/wenxiaofei/p/9853682.html)
1 change: 0 additions & 1 deletion Operating Systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,6 @@ IO多路复用(IO Multiplexing)是指单个进程/线程就可以同时处
### 待完成
- [ ] IPC
- [ ] 进程同步问题:生产者-消费者问题...
- [ ] 并发、并行、异步的区别
- [ ] 银行家算法
- [ ] 文件与文件系统、文件管理?
- [ ] 如何实现LRU缓存淘汰算法?
Binary file removed _v_images/20191208114637992_16460.jpg
Binary file not shown.
Binary file removed _v_images/20191208114719944_27728.jpg
Binary file not shown.

0 comments on commit 13b5810

Please sign in to comment.