第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

關(guān)于聯(lián)合索引的升序降序和order by關(guān)系以及失效問(wèn)題

關(guān)于聯(lián)合索引的升序降序和order by關(guān)系以及失效問(wèn)題

白衣染霜花 2019-02-21 12:11:51
Mysql: 之前看過(guò)一個(gè)說(shuō)法,說(shuō)order by后的各項(xiàng)如果排序不一致會(huì)導(dǎo)致聯(lián)合索引失效,譬如 order by a ASC, b DESC, c DESCa升序,b降序,排序不一致,索引(a,b,c)失效但是建索引的時(shí)候也可以指定排序如果建立一個(gè)索引(a ASC, b DESC, c DESC)那 order by a ASC, b DESC, c DESC 語(yǔ)句索引還失效嗎?
查看完整描述

2 回答

?
MYYA

TA貢獻(xiàn)1868條經(jīng)驗(yàn) 獲得超4個(gè)贊

mysql 文檔中對(duì)于索引定義中,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 是無(wú)效的,索引 (a ASC, b DESC, c DESC) 等于 (a ASC, b ASC, c ASC),故而無(wú)法使用整個(gè)聯(lián)合索引進(jìn)行排序。


查看完整回答
反對(duì) 回復(fù) 2019-02-21
?
30秒到達(dá)戰(zhàn)場(chǎng)

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個(gè)贊

8.0之后允許索引降序,拋開 sql 優(yōu)化等細(xì)節(jié),只要 order by 順序和索引順序一致,那么還是可以用到索引排序的。

(8.0)CREATE INDEX Syntax
(5.7)CREATE INDEX Syntax


查看完整回答
反對(duì) 回復(fù) 2019-02-21
  • 2 回答
  • 0 關(guān)注
  • 3925 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)