【发布时间】:2017-05-31 10:04:27
【问题描述】:
在过去的几天里,我们遇到了 MySQL(旧版本 5.1.69)的一些奇怪的性能问题。 慢日志显示如下内容:
# User@Host: jboss[jboss] @ localhost [127.0.0.1]
# Query_time: 46.595796 Lock_time: 0.000022 Rows_sent: 0 Rows_examined: 0
SET timestamp=1496127084;
insert into ACTIVE_RENT (LINE_ID, CHARGED_UP_TO, EVENT_ID, NUMBER, RENT_START, TYPE) values (149914, '2017-05-02 00:00:00', 625751, 'ABCD1234567', '2013-08-02 00:00:00', 'DETENTION');
# User@Host: jboss[jboss] @ localhost [127.0.0.1]
# Query_time: 19.401896 Lock_time: 0.000041 Rows_sent: 0 Rows_examined: 0
SET timestamp=1496127084;
delete from ACTIVE_RENT where ACTIVE_RENT_ID=463965;
删除或更新时没有指定级联,它只有一个指向另一个表的外键,并且该表没有触发器。这张桌子真的很基本。而且只有大约 14k 行。 通常这些插入或删除非常快,但最近几天在高峰期可能非常缓慢。
我们已将 innodb_buffer_size 增加到 20G,但这并没有太大变化(关于这个问题,其他东西更快)。目前数据库大小约为 40GB。 下面是my.conf。知道瓶颈可能来自哪里以及如何处理吗?我们正计划将 MySQL 升级到 5.5,但这在几周内不会发生。
[client]
default-character-set=utf8
socket=/home/mysql-data/mysql/mysql.sock
[mysql]
default-character-set=utf8
max_allowed_packet=32M
[mysqld]
# these are the install settings
local-infile=0
open_files_limit=8192
query_cache_size = 256M
query_cache_type = 1
query_cache_limit = 6M
query_prealloc_size = 16384
query_alloc_block_size = 2048
tmp_table_size = 128M
max_heap_table_size = 256M
table_cache = 1024
thread_cache_size = 512
key_buffer = 256M
join_buffer_size = 8M
read_buffer_size = 8M
sort_buffer_size = 8M
innodb_lock_wait_timeout = 120
binlog_format=row
max_allowed_packet=32M
log-bin=mysql-bin
server-id=1
#Allow group_concat to return longer data types
group_concat_max_len=16384
default-character-set = utf8
skip-character-set-client-handshake
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8
innodb_buffer_pool_size = 20GB
【问题讨论】:
-
检查服务器是否需要创建大量磁盘临时表...检查此变量的 SHOW STATUS 命令
Created_tmp_disk_tables...临时磁盘表是 MyISAM 表,这会导致很多 I /O 使服务器执行得更少...
标签: mysql database-performance