对于我来说,将索引放在日期字段上是否会有任何实际好处,这些日期字段将主要用于使用类似的东西的查询中.

dateField < 'var'

'var' BETWEEN dateField1 AND dateField2

搜索得到了很多,但我从来没有对它们进行直接比较“=”.
最佳答案
当然是.范围搜索将受益于索引,就像平等搜索一样.

引自MySQL Reference Manual :: How MySQL Uses Indexes:

B-Tree Index Characteristics

A B-tree index can be used for column comparisons in expressions that use the =,>,>=,<,<=,or BETWEEN operators. The index also can be used for LIKE comparisons if the argument to LIKE is a constant string that does not start with a wildcard character.

在某些情况下,如果范围最终会太大,优化器可能决定不使用索引,因为表扫描实际上可能更快.使用EXPLAIN查看将在查询中使用哪些(如果有)索引.

dawei