|
原始计划
mysql> explain select
-> s_acctbal,
-> s_name,
-> n_name,
-> p_partkey,
-> p_mfgr,
-> s_address,
-> s_phone,
-> s_comment
-> from
-> part,
-> supplier,
-> partsupp,
-> nation,
-> region
-> where
-> p_partkey = ps_partkey
-> and s_suppkey = ps_suppkey
-> and p_size = 15
-> and p_type like '%BRASS'
-> and s_nationkey = n_nationkey
-> and n_regionkey = r_regionkey
-> and r_name = 'EUROPE'
-> and ps_supplycost = (
-> select
-> min(ps_supplycost)
-> from
-> partsupp,
-> supplier,
-> nation,
-> region
-> where
-> p_partkey = ps_partkey
-> and s_suppkey = ps_suppkey
-> and s_nationkey = n_nationkey
-> and n_regionkey = r_regionkey
-> and r_name = 'EUROPE'
-> )
-> order by
-> s_acctbal desc,
-> n_name,
-> s_name,
-> p_partkey
-> limit 10;
+----+--------------------+----------+--------+---------------+---------+---------+---------------------------------------------+---------+---------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+--------------------+----------+--------+---------------+---------+---------+---------------------------------------------+---------+---------------------------------+
| 1 | PRIMARY | partsupp | index | PRIMARY | PRIMARY | 8 | NULL | 8000000 | Using temporary; Using filesort |
| 1 | PRIMARY | supplier | eq_ref | PRIMARY | PRIMARY | 4 | tpch.partsupp.ps_suppkey | 1 | |
| 1 | PRIMARY | nation | eq_ref | PRIMARY | PRIMARY | 4 | tpch.supplier.s_nationkey | 1 | |
| 1 | PRIMARY | region | index | PRIMARY | PRIMARY | 4 | NULL | 5 | Using where; Using join buffer |
| 1 | PRIMARY | part | eq_ref | PRIMARY | PRIMARY | 4 | tpch.partsupp.ps_partkey | 1 | Using where |
| 2 | DEPENDENT SUBQUERY | supplier | index | PRIMARY | PRIMARY | 4 | NULL | 100000 | |
| 2 | DEPENDENT SUBQUERY | nation | eq_ref | PRIMARY | PRIMARY | 4 | tpch.supplier.s_nationkey | 1 | |
| 2 | DEPENDENT SUBQUERY | region | index | PRIMARY | PRIMARY | 4 | NULL | 5 | Using where; Using join buffer |
| 2 | DEPENDENT SUBQUERY | partsupp | eq_ref | PRIMARY | PRIMARY | 8 | tpch.part.p_partkey,tpch.supplier.s_suppkey | 1 | |
+----+--------------------+----------+--------+---------------+---------+---------+---------------------------------------------+---------+---------------------------------+
9 rows in set (0.01 sec) |
|