操作符,否則將引擎放棄使用索引而進(jìn)行全表掃描。可以對(duì)2.對(duì)查詢進(jìn)行優(yōu)化,盡量避免全表掃描,首先應(yīng)考慮在 where 及 order by 涉及的列上建立索引..."/> 欧美日韩色另类综合,yin乱大合集,亚洲美女aⅴ久久久91

教育行業(yè)A股IPO第一股(股票代碼 003032)

全國(guó)咨詢/投訴熱線:400-618-4000

如何提高處理百萬(wàn)級(jí)以上的數(shù)據(jù)的查詢速度?

更新時(shí)間:2022年07月25日11時(shí)10分 來(lái)源:傳智教育 瀏覽次數(shù):

好口碑IT培訓(xùn)

1.應(yīng)盡量避免在 where 子句中使用!=或<>操作符,否則將引擎放棄使用索引而進(jìn)行全表掃描。

2.對(duì)查詢進(jìn)行優(yōu)化,應(yīng)盡量避免全表掃描,首先應(yīng)考慮在 where 及 order by 涉及的列上建立索引。

3.應(yīng)盡量避免在 where 子句中對(duì)字段進(jìn)行 null 值判斷,否則將導(dǎo)致引擎放棄使用索引而進(jìn)行全表掃描,如:

select id from t where num is null

可以在num上設(shè)置默認(rèn)值0,確保表中num列沒(méi)有null值,然后這樣查詢:

select id from t where num=0

4.應(yīng)盡量避免在 where 子句中使用 or 來(lái)連接條件,否則將導(dǎo)致引擎放棄使用索引而進(jìn)行全表掃描,如:

select id from t where num=10 or num=20

可以這樣查詢:

select id from t where num=10

union all

select id from t where num=20

5.下面的查詢也將導(dǎo)致全表掃描:(不能前置百分號(hào))

select id from t where name like ‘%abc%’

若要提高效率,可以考慮全文檢索。

0 分享到:
和我們?cè)诰€交談!