创建索引上的版本差异

关于索引的有趣现象:


今天在创建索引的时候,发现一个版本的差异。

在5.1版本创建索引.

mysql> create index idx_username on bk_user(username(20));

Query OK, 226 rows affected (0.11 sec)

Records: 226  Duplicates: 0  Warnings: 0


mysql> create index idx_email on bk_user(email(30));

Query OK, 226 rows affected (0.12 sec)

Records: 226  Duplicates: 0  Warnings: 0(在5.1创建的索引,它们的记录都是有着影响的。影响了226条)


(system@localhost) [baike]> show index from bk_user;(查看索引的时候,也是建好了的)

+---------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

| Table   | Non_unique | Key_name     | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |

+---------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

| bk_user |          0 | PRIMARY      |            1 | uid         | A         |       83799 |     NULL | NULL   |      | BTREE      |         |               |

| bk_user |          1 | loginstatus  |            1 | loginstatus | A         |           3 |     NULL | NULL   |      | BTREE      |         |               |

| bk_user |          1 | idx_username |            1 | username    | A         |       83799 |       20 | NULL   | YES  | BTREE      |         |               |

| bk_user |          1 | idx_email    |            1 | email       | A         |         185 |       30 | NULL   | YES  | BTREE      |         |               |

+---------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+

4 rows in set (0.00 sec)


在5.5版本上面,建立索引的时候。

(system@localhost) [baike]> create index idx_email on bk_user(email(30));

Query OK, 0 rows affected (0.49 sec)

Records: 0  Duplicates: 0  Warnings: 0(竟然发现0条数据,我被它欺骗了。其实是隐性的影响了相应的条数,你看时间0.49秒,就知道它是受了影响的)


这个现象挺有意思,说明mysql在版本的改变的时候,对这一块代码的实现做了修改。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值