日期:2014-05-16 浏览次数:21049 次
mysql> select count(*) from t1,t_06 where t1.id=t_06.id;
+----------+
| count(*) |
+----------+
|   100000 |
+----------+
1 row in set (1.89 sec)
mysql> select count(*) from t_06;
+----------+
| count(*) |
+----------+
|   499999 |
+----------+
1 row in set (0.02 sec)
mysql>
mysql> explain select * from t1,t_06 where t1.id=t_06.id;
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref     | rows   | Extra |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
|  1 | SIMPLE      | t1    | ALL    | PRIMARY       | NULL    | NULL    | NULL     | 100000 |       |
|  1 | SIMPLE      | t_06  | eq_ref | PRIMARY       | PRIMARY | 4       | test.t1.id |      1 |       |
+----+-------------+-------+--------+---------------+---------+---------+-------
-----+--------+-------+
2 rows in set (0.00 sec)
mysql> explain select * from t_06,t1 where t_06.id=t1.id;
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref     | rows   | Extra |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
|  1 | SIMPLE      | t1    | ALL    | PRIMARY       | NULL    | NULL    | NULL     | 100000 |       |
|  1 | SIMPLE      | t_06  | eq_ref | PRIMARY       | PRIMARY | 4       | test.t1.id |      1 |       |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
2 rows in set (0.00 sec)
mysql>
mysql> explain select * from t1 inner join t_06 using (id);
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref     | rows   | Extra |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
|  1 | SIMPLE      | t1    | ALL    | PRIMARY       | NULL    | NULL    | NULL     | 100000 |       |
|  1 | SIMPLE      | t_06  | eq_ref | PRIMARY       | PRIMARY | 4       | test.t1.id |      1 |       |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
2 rows in set (0.00 sec)
mysql> explain select * from t_06 inner join t1 using (id);
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
| id | select_type | table | type   | possible_keys | key     | key_len | ref     | rows   | Extra |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
|  1 | SIMPLE      | t1    | ALL    | PRIMARY       | NULL    | NULL    | NULL     | 100000 |       |
|  1 | SIMPLE      | t_06  | eq_ref | PRIMARY       | PRIMARY | 4       | test.t1.id |      1 |       |
+----+-------------+-------+--------+---------------+---------+---------+------------+--------+-------+
2 rows in set (0.00 sec)
mysql>