首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在MySQL5.5无害数据库中选择count(*) --重写通知?

问在MySQL5.5无害数据库中选择count(*) --重写通知?
EN

Database Administration用户
提问于 2013-04-08 12:04:16
回答 1查看 758关注 0票数 2

我需要关于如何重写无害数据库表MySQL5.5的select (*)查询的建议。在新的环境下非常缓慢..。

代码语言:javascript
复制
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;

查询执行计划看起来很简单,但速度非常慢。

代码语言:javascript
复制
*************************** 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)
EN

回答 1

Database Administration用户

发布于 2013-04-08 15:18:41

既然您已经有了必要的索引,那么考虑下一件事: Amazons

您很可能使用默认设置。在较小的RDS服务器模型中,您无法有效地调优InnoDB的多线程/多核使用。

关于内存的服务器模型使用情况,下面是一个图表

代码语言:javascript
复制
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)

由于计数需要通过许多数据和索引页,所以尝试使用更大的服务器模型。

我以前曾讨论过:

试试看!!

票数 2
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/39483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档