diff --git a/2014/12/24/MFC 模态对话框/index.html b/2014/12/24/MFC 模态对话框/index.html index e5c1eee9bd..4ebaaef1f8 100644 --- a/2014/12/24/MFC 模态对话框/index.html +++ b/2014/12/24/MFC 模态对话框/index.html @@ -301,7 +301,7 @@ diff --git a/2014/12/30/Clone-Graph-Part-I/index.html b/2014/12/30/Clone-Graph-Part-I/index.html index 82689fb55d..4c6a058664 100644 --- a/2014/12/30/Clone-Graph-Part-I/index.html +++ b/2014/12/30/Clone-Graph-Part-I/index.html @@ -300,16 +300,16 @@ diff --git a/2015/03/11/Reverse-Bits/index.html b/2015/03/11/Reverse-Bits/index.html index cdcf947201..7557d2ae58 100644 --- a/2015/03/11/Reverse-Bits/index.html +++ b/2015/03/11/Reverse-Bits/index.html @@ -300,19 +300,19 @@ diff --git a/2015/03/13/Reverse-Integer/index.html b/2015/03/13/Reverse-Integer/index.html index e3f170d5e3..2d69046c46 100644 --- a/2015/03/13/Reverse-Integer/index.html +++ b/2015/03/13/Reverse-Integer/index.html @@ -303,19 +303,19 @@ diff --git a/2015/04/14/Add-Two-Number/index.html b/2015/04/14/Add-Two-Number/index.html index a08ca2bdc9..7dd067ead2 100644 --- a/2015/04/14/Add-Two-Number/index.html +++ b/2015/04/14/Add-Two-Number/index.html @@ -312,10 +312,10 @@ diff --git a/2015/04/15/Leetcode-No-3/index.html b/2015/04/15/Leetcode-No-3/index.html index 2c5ea3a1b5..a422f008fb 100644 --- a/2015/04/15/Leetcode-No-3/index.html +++ b/2015/04/15/Leetcode-No-3/index.html @@ -303,16 +303,16 @@ diff --git a/2015/06/22/invert-binary-tree/index.html b/2015/06/22/invert-binary-tree/index.html index fbf373d8c2..1e61e87801 100644 --- a/2015/06/22/invert-binary-tree/index.html +++ b/2015/06/22/invert-binary-tree/index.html @@ -309,10 +309,10 @@ diff --git a/2016/08/14/34-Search-for-a-Range/index.html b/2016/08/14/34-Search-for-a-Range/index.html index 5f165a909c..8b628303c5 100644 --- a/2016/08/14/34-Search-for-a-Range/index.html +++ b/2016/08/14/34-Search-for-a-Range/index.html @@ -310,10 +310,10 @@ diff --git a/2016/08/14/docker-mysql-cluster/index.html b/2016/08/14/docker-mysql-cluster/index.html index 44acedcfe7..09a44254d7 100644 --- a/2016/08/14/docker-mysql-cluster/index.html +++ b/2016/08/14/docker-mysql-cluster/index.html @@ -305,10 +305,10 @@ diff --git a/2020/02/01/2019年终总结/index.html b/2020/02/01/2019年终总结/index.html index fff25ebb5d..0378566a62 100644 --- a/2020/02/01/2019年终总结/index.html +++ b/2020/02/01/2019年终总结/index.html @@ -318,13 +318,13 @@ diff --git a/2020/03/01/寄生虫观后感/index.html b/2020/03/01/寄生虫观后感/index.html index b948a82d0e..a9058124c8 100644 --- a/2020/03/01/寄生虫观后感/index.html +++ b/2020/03/01/寄生虫观后感/index.html @@ -313,10 +313,10 @@ diff --git a/2020/03/29/echo命令的一个小技巧/index.html b/2020/03/29/echo命令的一个小技巧/index.html index f32deebf2b..e66538ff48 100644 --- a/2020/03/29/echo命令的一个小技巧/index.html +++ b/2020/03/29/echo命令的一个小技巧/index.html @@ -317,10 +317,10 @@ diff --git a/2020/10/25/Leetcode-104-二叉树的最大深度-Maximum-Depth-of-Binary-Tree-题解分析/index.html b/2020/10/25/Leetcode-104-二叉树的最大深度-Maximum-Depth-of-Binary-Tree-题解分析/index.html index d71b365374..45a2845b20 100644 --- a/2020/10/25/Leetcode-104-二叉树的最大深度-Maximum-Depth-of-Binary-Tree-题解分析/index.html +++ b/2020/10/25/Leetcode-104-二叉树的最大深度-Maximum-Depth-of-Binary-Tree-题解分析/index.html @@ -326,13 +326,13 @@ diff --git a/2020/11/15/Leetcode-234-回文联表-Palindrome-Linked-List-题解分析/index.html b/2020/11/15/Leetcode-234-回文联表-Palindrome-Linked-List-题解分析/index.html index 7778ecd023..fac9cc1369 100644 --- a/2020/11/15/Leetcode-234-回文联表-Palindrome-Linked-List-题解分析/index.html +++ b/2020/11/15/Leetcode-234-回文联表-Palindrome-Linked-List-题解分析/index.html @@ -323,16 +323,16 @@ diff --git a/2020/12/06/Leetcode-155-最小栈-Min-Stack-题解分析/index.html b/2020/12/06/Leetcode-155-最小栈-Min-Stack-题解分析/index.html index 985e4dd74f..bd15e7b7c2 100644 --- a/2020/12/06/Leetcode-155-最小栈-Min-Stack-题解分析/index.html +++ b/2020/12/06/Leetcode-155-最小栈-Min-Stack-题解分析/index.html @@ -248,11 +248,11 @@ , - + , - + , @@ -324,6 +324,9 @@ + @@ -333,9 +336,6 @@ -
diff --git a/2020/12/13/Leetcode-105-从前序与中序遍历序列构造二叉树-Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal-题解分析/index.html b/2020/12/13/Leetcode-105-从前序与中序遍历序列构造二叉树-Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal-题解分析/index.html index caae24d639..d1e31ea4a6 100644 --- a/2020/12/13/Leetcode-105-从前序与中序遍历序列构造二叉树-Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal-题解分析/index.html +++ b/2020/12/13/Leetcode-105-从前序与中序遍历序列构造二叉树-Construct-Binary-Tree-from-Preorder-and-Inorder-Traversal-题解分析/index.html @@ -331,13 +331,13 @@ diff --git a/2020/12/27/聊聊-mysql-索引的一些细节/index.html b/2020/12/27/聊聊-mysql-索引的一些细节/index.html index b3045e06d2..9bf3f82dd7 100644 --- a/2020/12/27/聊聊-mysql-索引的一些细节/index.html +++ b/2020/12/27/聊聊-mysql-索引的一些细节/index.html @@ -34,8 +34,11 @@ + + + - + @@ -232,10 +235,16 @@ - - + + @@ -306,6 +315,11 @@


再来看看另一个

1
EXPLAIN select * from null_index_t WHERE null_key is not null;


从这里能看出来啥呢,可以思考下

+

从上面可以发现,is null应该是用上了索引了,所以至少不是一刀切不能用,但是看着is not null好像不太行额
我们在做一点小改动,把这个表里的数据改成 9100 条是 null,剩下 900 条是有值的,然后再执行下

然后再来看看执行结果

+
1
EXPLAIN select * from null_index_t WHERE null_key is null;
+

+
1
EXPLAIN select * from null_index_t WHERE null_key is not null;
+


是不是不一样了,这里再补充下我试验使用的 mysql 是 5.7 的,不保证在其他版本的一致性,
其实可以看出随着数据量的变化,mysql 会不会使用索引是会变化的,不是说 is not null 一定会使用,也不是一定不会使用,而是优化器会根据查询成本做个预判,这个预判尽可能会减小查询成本,主要包括回表啥的,但是也不一定完全准确。

@@ -319,10 +333,10 @@