降序索引(Descending Indexes)
先看下MySQL 8.0官方文档介绍:
DESC in an index definition is no longer ignored but causes storage of key values in descending order. Previously, indexes could be scanned in reverse order but at a performance penalty. A descending index can be scanned in forward order, which is more efficient.
大概意思是说在以前的版本是支持降序的方式扫描索引的,但是会带来额外的开销,降低性能。MySQL 8.0版本对此进行了改进,支持降序索引,降序索引可以高效率地以从后向前的顺序进行索引扫描。
测试
MySQL版本号: 8.0.1
测试表结构:
CREATE TABLE `t1` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`u1` int(10) unsigned NOT NUL