Mysql的整型到底需要不需要索引?

WBOY
Release: 2016-10-11 14:23:31
Original
1251 people have browsed it

Mysql 字段整型 常用来排序和筛选的到底需要不需要索引呢?一直很纠结。

回复内容:

Mysql 字段整型 常用来排序和筛选的到底需要不需要索引呢?一直很纠结。

加B-Tree索引有如下三个有点
1,减少服务器需要扫描的数据量。
2,可以帮助服务器避免排序和临时表。
3,可以将随机I/O变为顺序I/O。
如果数据表中的数量很小的情况可以先不加,简单的全表扫描更高效。对于中到大型的表,索引就非常有效。但对于特大型的表,建立和使用索引的代价将随之增长。这种情况下,则可以使用分区技术,查询需要的一组数据,而不是一条记录一条记录的匹配了。希望对你有帮助。

要看数据的离散程度,如果是学号之类连续的数据就不需要索引,电话号这样离散程度比较高的数据可以考虑设置一个索引 。

数据量大的话加 整型比字符效率高
题主可以看看索引优化方面的知识

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!