当前位置:   article > 正文

mysql 联合索引order_关于联合索引的升序降序和order by关系以及失效问题

多表联查ordery by 索引失效

mysql 文档中对于索引定义中,ASC 和 DESC 的描述

MySQL < 8.0A 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.0A 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),故而无法使用整个联合索引进行排序。

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/493959
推荐阅读
相关标签
  

闽ICP备14008679号