我有一个MySQL集群:(主人,两个奴隶)。最近(7天),我遇到了一个奇怪的问题:相同的在不同的db主机上有不同的成本。这个问题只发生在几个表上;
我想知道为什么和如何解决这个问题。主服务器花费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-日志Percona server (GPL),rel63.0版本,修订版519”
从服务器版本:“服务器版本: 5.6.22-71.0-log Percona server (GPL),第71.0版,修订版726”
这里是硬件
主从:操作系统内核: Linux 2.6.32-431.20.3.el6.mt20150216.x86_64操作系统: CentOS CPU : Intel(R) Xeon(R) CPU E5-2630 v2 @ 2.60GHz CPU num: 24 ram:130 1TB:( raid1,SAS 1TB*2 1TB)( raid5,SSD 480.0GB*6 2.4TB)


发布于 2015-07-24 03:10:23
(评论时间过长,不适合评论框):
仍然缺少一些信息:
主从mysql配置,然后主要是内存和磁盘数据位置(如果一个DB驻留在SSD上,另一个驻留在SAS 1TB磁盘上怎么办) 没有加载信息的主从:安装工具,如仙人掌与percona插件。
要获得更好的查询时间测试:注意在“新”实例中运行:在从上键入并重新测试查询。这将造成必须从磁盘加载所有数据的情况。
通常,在主机上以这种方式进行测试是否定的,因为它会在一段时间内减缓系统的运行速度(从磁盘重新加载所有数据来加热缓存需要时间(根据负载的不同,最多需要几个小时)。
https://stackoverflow.com/questions/31601017
复制相似问题