首先,我有以下表結構。爲什麼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