1:innodb底层实现原理:https://blog.csdn.net/u012978884/article/details/52416997

2:MySQL索引背后的数据结构及算法原理    http://blog.jobbole.com/24006/

3:B树,B+树,https://www.cnblogs.com/vincently/p/4526560.html

4:数据库使用B+树进行索引,B+树的插入删除都在叶子节点上进行。每个节点大小为一个page的大小,一般为4k,一个节点右多个关键字。

每个节点只保存索引信息,不保存记录信息,可以存放更多的key,数据更加紧密。 叶子节点用链表连接,一次遍历能都找到所有 的信息,有利于区间查找,范围查询,遍历。

为什么不用红黑树,因为红黑树的索引深度比较深。

5:B树相对于B树的优点,不用每次都查询到叶子节点。经常查询的可能离根节点更近。

6:

深入理解 MySQL 底层实现

https://blog.csdn.net/gitchat/article/details/78787837

7:索引失效的原因:

https://www.cnblogs.com/binyue/p/4058931.html

8:  数据库最左前缀,创建一个a,b,c索引,那么  除了b,c不可以用索引,其它组合都能用索引。但是a,c组合只能用到a的索引,c的索引用不上。和顺序无关。

https://blog.csdn.net/zly9923218/article/details/51330995

mysql> alter table newslist add index indexName(htmlid,pid,id);
Query OK, 0 rows affected
Records: 0 Duplicates: 0 Warnings: 0
mysql> select * from newslist;
+--------+-----+----+-------+--------------+---------------------------------+
| htmlid | pid | id | title | date_created | titleImage |
+--------+-----+----+-------+--------------+---------------------------------+
| 231 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 232 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 233 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 234 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 235 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 236 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 237 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 238 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 239 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 244 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 254 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 264 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 274 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 284 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
| 294 | 1 | 1 | ��Ŀ | 2017-02-08 | http://www.shiyanshi.com/my.jpg |
+--------+-----+----+-------+--------------+---------------------------------+
15 rows in set mysql> explain select * from newslist where pid=1 and id=1;
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | newslist | ALL | NULL | NULL | NULL | NULL | 15 | Using where |
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
1 row in set mysql> explain select * from newslist where htmlid=254 and pid=1 and id=1;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set mysql> explain select * from newslist where htmlid=254 and id=1;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set mysql> explain select * from newslist where htmlid=254 and pid=1;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set mysql> explain select * from newslist where pid=1 and id=1;
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | newslist | ALL | NULL | NULL | NULL | NULL | 15 | Using where |
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
1 row in set mysql> explain select * from newslist where pid=1 and htmlid=254;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set mysql> explain select * from newslist where pid=1 and htmlid=254;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set mysql> explain select * from newslist where id=1 and htmlid=254;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set mysql> explain select * from newslist where id=1 and pid=1;
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
| 1 | SIMPLE | newslist | ALL | NULL | NULL | NULL | NULL | 15 | Using where |
+----+-------------+----------+------+---------------+------+---------+------+------+-------------+
1 row in set
mysql> explain select * from newslist where id=1 and pid=1 and htmlid=254;
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
| 1 | SIMPLE | newslist | const | PRIMARY,indexName | PRIMARY | 8 | const | 1 | |
+----+-------------+----------+-------+-------------------+---------+---------+-------+------+-------+
1 row in set

9:mysql行锁的实现, 对索引进行加行锁。 InnoDB这种行锁实现特点意味着:只有通过索引条件检索数据,InnoDB才使用行级锁,否则,InnoDB将使用表锁!

https://blog.csdn.net/alexdamiao/article/details/52049993

数据库知识,mysql索引原理的更多相关文章

  1. Mysql数据库知识-Mysql索引总结 mysql mysql数据库 mysql函数

    mysql数据库知识-Mysql索引总结: 索引(Index)是帮助MySQL高效获取数据的数据结构. 下边是自己整理的资料与自己的学习总结,,做一个汇总. 一.真的有必要使用索引吗? 不是每一个性能 ...

  2. 重新学习MySQL数据库5:根据MySQL索引原理进行分析与优化

    重新学习MySQL数据库5:根据MySQL索引原理进行分析与优化 一:Mysql原理与慢查询 MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能 ...

  3. MySQL索引原理及慢查询优化

    原文:http://tech.meituan.com/mysql-index.html 一个慢查询引发的思考 select count(*) from task where status=2 and ...

  4. (转)MySQL索引原理及慢查询优化

    转自美团技术博客,原文地址:http://tech.meituan.com/mysql-index.html 建索引的一些原则: 1.最左前缀匹配原则,非常重要的原则,mysql会一直向右匹配直到遇到 ...

  5. MySQL索引原理及慢查询优化 转载

    原文地址: http://tech.meituan.com/mysql-index.html MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能 ...

  6. MySQL索引原理及慢查询优化(转)

    add by zhj:这是美团点评技术团队的一篇文章,讲的挺不错的. 原文:http://tech.meituan.com/mysql-index.html MySQL凭借着出色的性能.低廉的成本.丰 ...

  7. 【转载】MySQL索引原理及慢查询优化

    原文链接:美团点评技术团队:http://tech.meituan.com/mysql-index.html MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型 ...

  8. MySQL索引原理与慢查询优化

    索引目的 索引的目的在于提高查询效率,可以类比字典,如果要查“mysql”这个单词,我们肯定需要定位到m字母,然后从下往下找到y字母,再找到剩下的sql.如果没有索引,那么你可能需要把所有单词看一遍才 ...

  9. 干货:MySQL 索引原理及慢查询优化

    MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能出色,但所谓"好马配好鞍",如何能够更好的使用它,已经成为开发工程师的必修 ...

  10. MySQL索引原理及慢查询优化(转自:美团tech)

    背景 MySQL凭借着出色的性能.低廉的成本.丰富的资源,已经成为绝大多数互联网公司的首选关系型数据库.虽然性能出色,但所谓“好马配好鞍”,如何能够更好的使用它,已经成为开发工程师的必修课,我们经常会 ...

随机推荐

  1. 【matlab】error:试图访问 im2(1,1211);由于 size(im2)=[675,1210],索引超出范围。

    试图访问 im2(1,1211):由于 size(im2)=[675,1210],索引超出范围. 出错 dect (line 14) if abs((im2(i,j))-(im1(i,j)))> ...

  2. [hibernate]org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type setter

    org.hibernate.PropertyAccessException: Null value was assigned to a property of primitive type sette ...

  3. mybatis由浅入深day02_8spring和mybatis整合

    8 spring和mybatis整合 8.1 整合思路 需要spring通过单例方式管理SqlSessionFactory.mapper接口. spring和mybatis整合生成代理对象,使用Sql ...

  4. Effective C++ Item 12 Copy all parts of an object

    This one is simple, do not forget to copy all parts of an object in copy constructor or assignment o ...

  5. POJ 1321 棋盘问题(状态压缩DP)

    不总结的话, 同一个地方会 WA 到死 思路: 状态压缩 DP. 1. s 表示压缩状态, 若第 i 列放了棋子, 那么该列置 1, 否则该列置 0. 假如 s = 3(0x011) 那么表示棋盘的第 ...

  6. 08python之列表的常用方法

    列表list是python常用的数据类型,需要掌握以下常用方法: name_list = ['alex','tenglan','65brother'] 这个变量和之前的变量只存一个数字或字符串,这个列 ...

  7. break、continue、return之间的区别与联系

    今天在部署程序的时候,监控日志发现这个问题了.return的问题就这么总结哈. 在软件开发过程中,逻辑清晰是非常之重要的. 代码的规范也是非常重要的.往往细节决定成败.在编写代码的时候,一定要理解语言 ...

  8. WAS的部署

    一.设置JAM参数 1.登录WAS的控制台 https://192.168.0.91:9043/ibm/console

  9. onTouch

    OnTouchOmOnTouchListenerOnTouchEvent View的事件分发 :    对于事件分发机制,举个简单的例子,在一个Activity中只有一个按钮,如果我们想给这个按钮注册 ...

  10. ubuntu的安装方法

    Ubuntu 是一个启动速度超快.界面友好.安全性好的开源操作系统,它由全球顶尖开源软件专家开发,适用于桌面电脑.笔记本电脑.服务器以及上网本等,并且它可以永久免费使用.如果你厌倦了Windows,如 ...