【发布时间】:2012-02-13 10:49:23
【问题描述】:
我有一个带有from_uid 和to_uid(均已编入索引)的链接表,我想过滤掉某些ID。所以我这样做:
SELECT l.uid
FROM Link l
JOIN filter_ids t1 ON l.from_uid = t1.id
JOIN filter_ids t2 ON l.to_uid = t2.id
现在由于某种原因,这出乎意料地慢:(而每个单独的连接都非常快。它不能使用索引吗?
EXPLAIN 告诉我:
id select table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 index Null PRIMARY 34 Null 12205 Using index
1 SIMPLE l ref from_uid,to_uid from_uid 96 func 6 Using where
1 SIMPLE t2 index Null PRIMARY 34 Null 12205 Using where; Using index; Using join buffer
【问题讨论】:
标签: mysql performance join indexing