mysql 'OR','IN',‘union’效率分析

1、
EXPLAIN (SELECT * FROM m_news WHERE TYPES = 5 ) UNION (SELECT * FROM m_news WHERE TYPES = 10 );

 

2、
EXPLAIN SELECT * FROM m_news WHERE TYPES = 5 OR TYPES =10;

 

3、
EXPLAIN SELECT * FROM m_news WHERE TYPES IN (5,10);




结论:从影响行数来说,用'or'和‘in’ 效果是一样的,‘union’效率高很多。

posted @ 2012-04-09 12:29  小伍BLOG  阅读(1309)  评论(0编辑  收藏  举报