MySQL中Join算法实现原理分析
2009-04-04 11:18:13 来源:WEB开发网使用Query如下:
1 select m.subject msg_subject, c.content msg_content
2
3 from user_group g,group_message m,group_message_content c
4
5 where g.user_id = 1
6
7 and m.group_id = g.group_id
8
9 and c.group_msg_id = m.id
看看我们的 Query 的执行计划:
1 sky@localhost : example 11:17:04> explain select m.subject msg_subject, c.content msg_content
2
3 -> from user_group g,group_message m,group_message_content c
4
5 -> where g.user_id = 1
6
7 -> and m.group_id = g.group_id
8
9 -> and c.group_msg_id = m.idG
10
11 *************************** 1. row ***************************
12
13 id: 1
14
15 select_type: SIMPLE
16
17 table: g
18
19 type: ref
20
21 possible_keys: user_group_gid_ind,user_group_uid_ind,user_group_gid_uid_ind
22
23 key: user_group_uid_ind
24
25 key_len: 4
26
27 ref: const
28
29 rows: 2
30
31 Extra:
32
33 *************************** 2. row ***************************
34
35 id: 1
36
37 select_type: SIMPLE
38
39 table: m
40
41 type: ref
42
43 possible_keys: PRIMARY,idx_group_message_gid_uid
44
45 key: idx_group_message_gid_uid
46
47 key_len: 4
48
49 ref: example.g.group_id
50
51 rows: 3
52
53 Extra:
54
55 *************************** 3. row ***************************
56
57 id: 1
58
59 select_type: SIMPLE
60
61 table: c
62
63 type: ref
64
65 possible_keys: idx_group_message_content_msg_id
66
67 key: idx_group_message_content_msg_id
68
69 key_len: 4
70
71 ref: example.m.id
72
73 rows: 2
74
75 Extra:
- ››MySql数据库插入式的多存储引擎机制
- ››MySQL和PDO测试对比
- ››MySQL大表中重复字段的查询效率方法
- ››MySQL中BLOB字段类型介绍
- ››mysql 数据库查询随机数量条目的效率问题及解决办...
- ››MySQL中两种索引Hash与B-Tree的区别
- ››MySql存储过程 带参数处理方式
- ››MySQL数据表在phpmyadmin中的强制修复
- ››MySQL 5 乱码问题处理办法
- ››mysql sql语法错误 1149
- ››MySQL 1040 错误 Too many connections
- ››MySQL client ran out of memory(2008)
赞助商链接