I need advice on how to rewrite a select count(*) query for innodb tables mysql 5.5. in new environment its very slow...
select count(*)
from mails3
join questions using (question_id)
where mails3.from_user_id = '86696'
and mails3.is_community_star = 1
and mails3.rating = 3
and questions.is_rated_community = 1;
the query execution plan looks simple enough but very slow
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: mails3
type: ref
possible_keys: question_id_index,emails_doublestars,favorite_emails,user_responses,owner_responses,sentmail,watchlist,read_responses,rating_date,read_and_unrated
key: emails_doublestars
key_len: 8
ref: const,const,const
rows: 2784
Extra: Using where
*************************** 2. row ***************************
id: 1
select_type: SIMPLE
table: questions
type: eq_ref
possible_keys: PRIMARY,is_rated_community_senddate_idx
key: PRIMARY
key_len: 5
ref: answerology.mails3.QUESTION_ID
rows: 1
Extra: Using where
2 rows in set (0.00 sec)