详解MySQL三项实用开发知识
2009-04-02 11:18:19 来源:WEB开发网user是联合索引的名称,包含3个列,分别是username,order,email。接下来执行以下sql,使用explain命令来分析下运行结果。
代码:
mysql> explain select * from user where username='leehui';
+----+-------------+-------+------+---------------+------+---------+-------+------+--------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+-------+------+--------+
| 1 | SIMPLE| user | ref | user | user | 152 | const | 1 | Using where |
+----+-------------+-------+------+---------------+------+---------+-------+------+--------+
1 row in set (0.00 sec)
mysql> explain select * from user where pws='123';
+----+-------------+-------+------+---------------+------+---------+------+------+---------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-------+------+---------------+------+---------+------+------+---------+
| 1 | SIMPLE| user | ALL | NULL | NULL | NULL | NULL | 2 | Using where |
+----+-------------+-------+------+---------------+------+---------+------+------+---------+
1 row in set (0.00 sec)
更多精彩
赞助商链接