我需要关于如何重写无害数据库表MySQL5.5的select (*)查询的建议。在新的环境下非常缓慢..。
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;查询执行计划看起来很简单,但速度非常慢。
*************************** 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)发布于 2013-04-08 15:18:41
既然您已经有了必要的索引,那么考虑下一件事: Amazons
您很可能使用默认设置。在较小的RDS服务器模型中,您无法有效地调优InnoDB的多线程/多核使用。
关于内存的服务器模型使用情况,下面是一个图表
MODEL max_connections innodb_buffer_pool_size
--------- --------------- -----------------------
t1.micro 34 326107136 ( 311M)
m1-small 125 1179648000 ( 1125M, 1.097G)
m1-large 623 5882511360 ( 5610M, 5.479G)
m1-xlarge 1263 11922309120 (11370M, 11.103G)
m2-xlarge 1441 13605273600 (12975M, 12.671G)
m2-2xlarge 2900 27367833600 (26100M, 25.488G)
m2-4xlarge 5816 54892953600 (52350M, 51.123G)由于计数需要通过许多数据和索引页,所以尝试使用更大的服务器模型。
我以前曾讨论过:
试试看!!
https://dba.stackexchange.com/questions/39483
复制相似问题