立即學習:https://edu.csdn.net/course/play/25283/297143?utm_source=blogtoedu
explain +sql ;
id 值相同,從上往下順序執行
表的執行順序 因數量的個數改變而改變的原因:笛卡爾積
數據小的表,優先查詢
id值不同:id值越大越優先查詢
(2)select_type
primary :包含子查詢SQL中的主查詢(最外層)
SUBQUERY:包含子查詢SQL中的子查詢(非最外層)
simple:簡單查詢(不包含子查詢、union)
derived:衍生查詢(使用到了臨時表)
a.在from 子查詢中只有一張表
b.在from子查詢中,如果有table1 union table2,則table1 就是derived table2 就是union
union result 表(不常見)