MySQL 索引 NULL 值吗? [英] Does MySQL index NULL values?

查看:27
本文介绍了MySQL 索引 NULL 值吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 MySQL 表,其中索引 INT 列对于 90% 的行将是 0.如果我将这些行更改为使用 NULL 而不是 0,它们是否会被排除在索引之外,从而使索引小 90% 左右?

I have a MySQL table where an indexed INT column is going to be 0 for 90% of the rows. If I change those rows to use NULL instead of 0, will they be left out of the index, making the index about 90% smaller?

推荐答案

http://dev.mysql.com/doc/refman/5.0/en/is-null-optimization.html

MySQL 可以对 col_name IS NULL 执行相同的优化,它可以用于 col_name = constant_value.例如,MySQL 可以使用索引和范围来搜索 NULLIS NULL.

MySQL can perform the same optimization on col_name IS NULL that it can use for col_name = constant_value. For example, MySQL can use indexes and ranges to search for NULL with IS NULL.

这篇关于MySQL 索引 NULL 值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆