是否需要将具有数字的数据库列编入索引?

时间:2016-04-25 16:38:20

标签: sql database database-indexes database-optimization

假设鲍勃得到107分,玛丽得到105分,约翰得到105积分。这些数字可能会改变,也不是唯一的。 现在我想查询并检查订单,谁在最顶层,谁在底部。保存点的那列是否需要编入索引?

2 个答案:

答案 0 :(得分:4)

这取决于所使用的数据库系统和表的大小(行数)。

如果表足够小并且您正在使用MSSQL,例如a table scan will be used(整个表将被读入内存)并且索引将相对无用。

一般来说,是 - 字段should be indexed if that is the column you'll be using to select or sort data

答案 1 :(得分:1)

作为一般规则,我考虑索引出现在常用查询的$result -> array(1) { [1] => string(26) "secondset=blue;yellow;red;" } $resultString -> string(26) "secondset=blue;yellow;red;" WHERE子句中的列。