Mysql中SQL優化執行計劃中的連線方式淺釋
阿新 • • 發佈:2018-12-10
關係庫SQL調優中,雖然思路都是一樣的,具體方法和步驟也是大同小異,但細節卻不容忽視,尤其是執行計劃的具體細節的解讀中,各關係庫確實有區別,特別是mysql資料庫,與其他關係庫的差別更大些,下面,我們僅就SQL執行計劃中最常見的連線方式,做以下簡要介紹和說明。
system
: a system table which is a constant table(訪問一個常量系統表);-
const
: a constant table(訪問一個常量表); -
eq_ref
: a unique or primary index with an equality relation(通過等值操作去訪問一個唯一或主鍵索引); -
ref
: an index with an equality relation, where the index value cannot beNULL(通過一個等值操作去訪問一個不包含null值的索引);
-
ref_or_null
: an index with an equality relation, where it is possible for the index value to beNULL(通過等值操作去訪問一個可能包含null值得索引);
-
range
: an index with a relation such asBETWEEN
,IN
>=
,LIKE
, and so on(通過類似between,in,>=,like等操作去訪問一個索引); -
index
: a sequential scan on an index(通過順序掃描方式訪問一個索引); -
ALL
: a sequential scan of the entire table(通過順序掃描方式訪問整張表)。
此外,mysql中,無論對錶或索引的訪問操作還是多表間的連線操作,一般都統稱為連線,這裡,大家需要注意點。