mysql索引升序降序失效原因_关于联合索引的升序降序和order by关系以及失效问题...
mysql 文檔中對于索引定義中,ASC 和 DESC 的描述
MySQL < 8.0
A key_part specification can end with ASC or DESC. These keywords are permitted for future extensions for specifying ascending or descending index value storage.
Currently, they are parsed but ignored; index values are always stored in ascending order.
MySQL >= 8.0
A key_part specification can end with ASC or DESC to specify whether index values are stored in ascending or descending order. The default is ascending if no order specifier is given. ASC and DESC are not permitted for HASH indexes. As of MySQL 8.0.12, ASC and DESC are not permitted for SPATIAL indexes.
所以,在8.0之前的版本中, DESC 是無效的,索引 (a ASC, b DESC, c DESC) 等于 (a ASC, b ASC, c ASC),故而無法使用整個聯(lián)合索引進行排序。
8.0之后允許索引降序,拋開 sql 優(yōu)化等細節(jié),只要 order by 順序和索引順序一致,那么還是可以用到索引排序的。
總結(jié)
以上是生活随笔為你收集整理的mysql索引升序降序失效原因_关于联合索引的升序降序和order by关系以及失效问题...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 访客手机抓取
- 下一篇: java短信接口demo_java开发调