Mysql慢并发GROUP BY查询

时间:2015-05-05 14:27:40

标签: mysql sql group-by

我对mysql和GROUP BY查询有一些奇怪的问题。见下文:

mysqlslap --concurrency=5 --iterations=1 --query=/root/test.sql --create-     schema=testd  -u root -p
Benchmark
        Average number of seconds to run all queries: 2.575 seconds
        Minimum number of seconds to run all queries: 2.575 seconds
        Maximum number of seconds to run all queries: 2.575 seconds
        Number of clients running queries: 5
        Average number of queries per client: 1

但是,当我只运行1个查询时,它将如下所示:

mysqlslap --concurrency=1 --iterations=1 --query=/root/test.sql --create-    schema=testd  -u root -p
Benchmark
        Average number of seconds to run all queries: 0.247 seconds
        Minimum number of seconds to run all queries: 0.247 seconds
        Maximum number of seconds to run all queries: 0.247 seconds
        Number of clients running queries: 1
        Average number of queries per client: 1

test.sql文件只包含这一个查询:

SELECT SQL_NO_CACHE `name` FROM logs GROUP BY `name`;

当我删除GROUP BY时,它执行得很好,并且不会像以前一样减速。

Mysql版本是5.5.43。 CPU为E5-1660v3,有32GB RAM可用。 my.cnf文件是默认值,但这些值除外:

key_buffer              = 256M
key_buffer_size         = 256M
sort_buffer_size    = 2M
read_rnd_buffer_size    = 1M
innodb_buffer_pool_size = 1G
max_allowed_packet      = 32M
thread_stack            = 192K
thread_cache_size       = 8
myisam-recover          = BACKUP
max_connections     = 300
table_cache     = 256M
query_cache_limit       = 1M
query_cache_size        = 16M

任何想法可能是什么问题?

0 个答案:

没有答案