问题
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