1.simple 簡單查詢。查詢不包含子查詢和union,我們碰到的大部分查詢都是簡單查詢。
執行以下sql語句:
explain select (select 1 from actor where id = 1) from
(select * from film where id = 1
union
select * from film where id = 1
) der;
會出現另外5中查詢類型
#2.primary:復雜查詢中最外層的 select(explain后面的第一個select)
#3.derived:包含在 from 子句中的子查詢。MySQL會將結果存放在一個臨時表中,也稱為派生表(derived的英文含義)
#4.union:在 union 中的第二個和隨后的 select,使用union關鍵字時,因為是臨時表,所以無法使用索引,查詢效率會比較低
#5.union result:從 union 臨時表檢索結果的 select
#6.subquery:包含在 select 中的子查詢(不在 from 子句中)