碰到的查询的疑问
資深大佬 : wuxi889 6
今天在做查询优化时,碰到了一个问题:百万级别的索引查询时,SELECT id
(主键) 与 SELECT session_id
(普通索引) 的查询速度差了一大截,EXPLAIN 的剖析结果两条查询语句是一致的。
SQL1 SELECT id FROM table WHERE path_type=’products’; // 耗时 0.5s 左右
SQL2 SELECT session_id FROM table WHERE path_type=’products’; // 耗时 7s 左右
EXPLAIN 两个 SQL 相同 1 SIMPLE statistics_page_visits ref statistics_page_visits_path_type_index statistics_page_visits_path_type_index 1023 const 1144028 100.00 Using index
请问造成以上结果的原因是什么 @_@ 晕乎
大佬有話說 (10)