首先,我有以下表结构。为什么Mysql不在索引列上使用INNER JOIN表的索引?
Table Document
## DocID ## ##DocName ##
1 Doc1
2 Doc2
3 Doc3
Table FolderTree
## FolderID ## ## MemberDocID ##
1 1
1 2
1 3
我对的DocID,FolderID和MemberDocID
我有以下查询索引。
SELECT DISTINCT d.* FROM Document d inner join FolderTree f on (d.DocID = f.MemberDocID) where f.FolderID = 1
explain输出:
| select type | table | type | possible_keys | key | rows | extra |
simple d All PRIMARY NULL 83168 Using temporary
simple f ref MemberDocID MemberDocID 11 Using index
我的问题是,为什么在表d MySQL的使用表扫描,其中i上的DocID有指标?
谢谢先进。
@bernie此处的根本原因与链接的可能重复中的原因不同。虽然他们听起来像是类似的问题,但他们不是。 – 2013-02-22 21:46:54