mysql 基於規則的執行計劃
oracle 裡有基於規則的執行計劃,不過現在很少用了。mysql裡也有這種,不過看起來很弱智,還是我的錯覺,明天繼續:
mysql> set profiling=1;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2;
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| id | teacherId | classId | description | id | classId | studentId | description |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| 2 | 900002 | 2 | NULL | 2 | 2 | 100002 | NULL |
| 2 | 900002 | 2 | NULL | 3 | 2 | 100003 | NULL |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
2 rows in set (0.01 sec)
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| id | teacherId | classId | description | id | classId | studentId | description |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| 2 | 900002 | 2 | NULL | 2 | 2 | 100002 | NULL |
| 2 | 900002 | 2 | NULL | 3 | 2 | 100003 | NULL |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
2 rows in set (0.01 sec)
mysql> SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2;
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| id | classId | studentId | description | id | teacherId | classId | description |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| 2 | 2 | 100002 | NULL | 2 | 900002 | 2 | NULL |
| 3 | 2 | 100003 | NULL | 2 | 900002 | 2 | NULL |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
2 rows in set (0.00 sec)
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| id | classId | studentId | description | id | teacherId | classId | description |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| 2 | 2 | 100002 | NULL | 2 | 900002 | 2 | NULL |
| 3 | 2 | 100003 | NULL | 2 | 900002 | 2 | NULL |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
2 rows in set (0.00 sec)
mysql> show profiles;
+----------+------------+----------------------------------------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+----------------------------------------------------------------------------------------------+
| 1 | 0.00133400 | SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2 |
| 2 | 0.00111300 | SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2 |
+----------+------------+----------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
+----------+------------+----------------------------------------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+----------------------------------------------------------------------------------------------+
| 1 | 0.00133400 | SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2 |
| 2 | 0.00111300 | SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2 |
+----------+------------+----------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2;
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| id | teacherId | classId | description | id | classId | studentId | description |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| 2 | 900002 | 2 | NULL | 2 | 2 | 100002 | NULL |
| 2 | 900002 | 2 | NULL | 3 | 2 | 100003 | NULL |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
2 rows in set (0.00 sec)
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| id | teacherId | classId | description | id | classId | studentId | description |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
| 2 | 900002 | 2 | NULL | 2 | 2 | 100002 | NULL |
| 2 | 900002 | 2 | NULL | 3 | 2 | 100003 | NULL |
+----+-----------+---------+-------------+----+---------+-----------+-------------+
2 rows in set (0.00 sec)
mysql> SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2;
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| id | classId | studentId | description | id | teacherId | classId | description |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| 2 | 2 | 100002 | NULL | 2 | 900002 | 2 | NULL |
| 3 | 2 | 100003 | NULL | 2 | 900002 | 2 | NULL |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
2 rows in set (0.00 sec)
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| id | classId | studentId | description | id | teacherId | classId | description |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
| 2 | 2 | 100002 | NULL | 2 | 900002 | 2 | NULL |
| 3 | 2 | 100003 | NULL | 2 | 900002 | 2 | NULL |
+----+---------+-----------+-------------+----+-----------+---------+-------------+
2 rows in set (0.00 sec)
mysql> show profiles;
+----------+------------+----------------------------------------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+----------------------------------------------------------------------------------------------+
| 1 | 0.00133400 | SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2 |
| 2 | 0.00111300 | SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2 |
| 3 | 0.00087100 | SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2 |
| 4 | 0.00065500 | SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2 |
+----------+------------+----------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)
+----------+------------+----------------------------------------------------------------------------------------------+
| Query_ID | Duration | Query |
+----------+------------+----------------------------------------------------------------------------------------------+
| 1 | 0.00133400 | SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2 |
| 2 | 0.00111300 | SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2 |
| 3 | 0.00087100 | SELECT * FROM teacher_class A, student_class B where A.classId = B.classId AND B.classId = 2 |
| 4 | 0.00065500 | SELECT * FROM student_class B,teacher_class A where A.classId = B.classId AND B.classId = 2 |
+----------+------------+----------------------------------------------------------------------------------------------+
4 rows in set (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-680904/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql 基於規則的執行計劃(二)MySql
- 執行計劃-3:解釋規則
- explain執行計劃中的key_len的計算規則AI
- MySQL 執行計劃MySql
- MySQL執行計劃MySql
- 執行計劃執行步驟原則
- mysql執行計劃explainMySqlAI
- mysql explain 執行計劃MySqlAI
- MySQL執行計劃解析MySql
- MySQL執行計劃解析(四)MySql
- 讀懂MySQL執行計劃MySql
- 讀懂 MySQL 執行計劃MySql
- mysql索引和執行計劃MySql索引
- MySQL中in(常量列表)的執行計劃MySql
- 【MySQL】MySQL的執行計劃及索引優化MySql索引優化
- 帶你看懂MySQL執行計劃MySql
- MySQL Explain執行計劃 - 詳解MySqlAI
- 十六、Mysql之Explain執行計劃MySqlAI
- mysql explain 執行計劃詳解MySqlAI
- MySQL執行計劃EXPLAIN詳解MySqlAI
- drools執行完某個規則後終止別的規則執行
- mysql的執行計劃快取問題MySql快取
- drools執行指定的規則
- 管理規則和基於規則的轉換——流
- 基於UNION ALL的分頁查詢執行計劃問題
- 關於索引的執行計劃記載索引
- drools執行String規則或執行某個規則檔案
- mysql調優之——執行計劃explainMySqlAI
- mysql 執行計劃索引分析筆記MySql索引筆記
- (4) MySQL中EXPLAIN執行計劃分析MySqlAI
- mysql主從庫執行計劃不同MySql
- MySQL 5.7獲取指定執行緒正在執行SQL的執行計劃資訊MySql執行緒
- 執行計劃-1:獲取執行計劃
- MySQL——通過EXPLAIN分析SQL的執行計劃MySqlAI
- MySql中執行計劃如何來的——Optimizer TraceMySql
- MySQL執行計劃explain的key_len解析MySqlAI
- CSS規則的執行順序CSS
- 分析執行計劃優化SQLORACLE的執行計劃(轉)優化SQLOracle