Master和slave之间的大MySQL性能差异

时间:2015-07-24 02:04:32

标签: mysql performance explain

我有一个MySQL集群:(主人,两个奴隶)。 最近(7天),我遇到了一个奇怪的问题:同一个SQL在不同的数据库主机上有不同的成本。 此问题仅发生在几个表;

我想知道为什么以及如何解决这个问题。  主费用2.47秒

mysql> explain select id from notification_message where expire_time < '2015-07-23' limit 1\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: notification_message
         type: range
possible_keys: idx_expire_time
          key: idx_expire_time
      key_len: 6
          ref: NULL
         rows: 5414595
        Extra: Using where; Using index
1 row in set (0.00 sec)

mysql>  select id from notification_message where expire_time < '2015-07-23' limit 1\G
*************************** 1. row ***************************
id: 186925000
1 row in set (2.47 sec)

从属费用0.00秒

mysql> explain select id from notification_message where expire_time < '2015-07-23' limit 1\G
*************************** 1. row ***************************
           id: 1
  select_type: SIMPLE
        table: notification_message
         type: range
possible_keys: idx_expire_time
          key: idx_expire_time
      key_len: 6
          ref: NULL
         rows: 4999367
        Extra: Using where; Using index
1 row in set (0.00 sec)

mysql> select id from notification_message where expire_time < '2015-07-23' limit 1;
+-----------+
| id        |
+-----------+
| 186925000 |
+-----------+
1 row in set (0.00 sec)

这是mysql版本

主服务器版本: “服务器版本:5.6.15-56-log Percona Server(GPL),版本rel63.0,修订版519”

奴隶服务器版本: “服务器版本:5.6.22-71.0-log Percona Server(GPL),版本71.0,修订版726”

这是硬件

掌握与奴隶相同:        os core:Linux 2.6.32-431.20.3.el6.mt20150216.x86_64           操作系统:CentOS     CPU:Intel(R)Xeon(R)CPU E5-2630 v2 @ 2.60GHz     CPU数量:24         ram:130GB        RAID:(raid1,SAS [1TB * 2] 1TB)(raid5,SSD [480.0GB * 6] 2.4TB)

load of master enter image description here

1 个答案:

答案 0 :(得分:0)

(评论框备注太久了):

仍然缺少一些信息:

  

主和从mysql配置,然后主要是内存和磁盘数据位置(如果一个DB存在于SSD而另一个存在于SAS 1TB磁盘上,则该怎么办)

     

主人和主人的无负载信息; slave:使用percona插件安装像cacti这样的工具。

要更好地测试查询时间:注意在“新鲜”实例中运行:在从属上键入flush query cache并重新测试查询。这将创建一个必须从磁盘加载所有数据的情况。

通常在主服务器上以这种方式进行测试是否定的,因为它会使系统运行一段时间(从磁盘重新加载所有数据以加热缓存需要时间(根据负载而长达数小时))。< / p>

相关问题