select count(*) from commun_message where (from_read_status=0 and to_user_status=2 and from_user_id='qingwen' and message_type=3 )or( to_read_status=0 and to_user_id='qingwen' and to_user_status=1 and message_type=3 ) -> select count(*) from commun_message where from_read_status in(0,1) and to_user_status in(1,2) and from_user_id='qingwen' and message_type=3 explain SQL语句,看看结果就行了
explain SQL语句,看看结果就行了 怎么explain啊?
select sum(mc) from ( select count(*) as mc from commun_message where from_read_status=0 and to_user_status=2 and from_user_id='qingwen' and message_type=3 union all select count(*) from commun_message where to_read_status=0 and to_user_id='qingwen' and to_user_status=1 and message_type=3 ) a如果有合适的索引explain select count(*) from commun_message where ((from_read_status=0 and to_user_status=2 and from_user_id='qingwen')or( to_read_status=0 and to_user_id='qingwen' and to_user_status=1)) and message_type=3
->
select count(*) from commun_message where from_read_status in(0,1) and to_user_status in(1,2) and from_user_id='qingwen' and message_type=3 explain SQL语句,看看结果就行了
select count(*) as mc from commun_message where from_read_status=0 and to_user_status=2 and from_user_id='qingwen' and message_type=3
union all
select count(*) from commun_message where
to_read_status=0 and to_user_id='qingwen' and to_user_status=1 and message_type=3 ) a如果有合适的索引explain select count(*) from commun_message where ((from_read_status=0 and to_user_status=2 and from_user_id='qingwen')or( to_read_status=0 and to_user_id='qingwen' and to_user_status=1)) and message_type=3