Mysql slow concurrent GROUP BY queries

蹲街弑〆低调 提交于 2019-12-12 06:18:59

问题


I have weird problem with mysql and GROUP BY queries. See below:

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

But when I'm running just 1 query it will look like this:

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 file includes just this one query:

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

When I remove GROUP BY it executes just fine and doesn't slow down like before.

Mysql version is 5.5.43. CPU is E5-1660v3 and there is 32GB RAM available. my.cnf file is default except these values:

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

Any ideas what could be the problem?

来源:https://stackoverflow.com/questions/30055789/mysql-slow-concurrent-group-by-queries

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!