Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL server uses only 1 out of 48 CPU cores with GROUP BY queries

I have high end 48 CPU core server with latest MySQL 5.7 installed

I'm bit surprised that when executing queries with GROUP BY, no matter how I format my query I get only 1 CPU core used for that query, clearly illustrated by htop output

Of course I can perform multiple queries at the same time, and that's how I can use all the cores but it seems not too convenient and not every query can be split to use full server's power

Are there any MySQL extensions or SQL hints that allow to use multiple cores while processing data with GROUP BY?

like image 548
Matthias Avatar asked Mar 01 '17 10:03

Matthias


1 Answers

As the accepted answer by RolandoMySQLDBA to Possible to make MySQL use more than one core? question says:

I actually discussed innodb_thread_concurrency with a MySQL Expert at the Percona Live NYC conference back in May 2011.

I learned something surprising: In spite of the documentation, it is best to leave innodb_thread_concurrency at 0 (infinite concurrency). That way, InnoDB decides the best number of innodb_concurrency_tickets to open for a given MySQL instance setup.

Once you set innodb_thread_concurrency to 0, you can set innodb_read_io_threads and innodb_write_io_threads (both since MySQL 5.1.38) to the maximum value of 64. This should engage more cores.

This is the best guidance I ever found on how to make MySQL use more cores in general.

like image 89
Shadow Avatar answered Sep 27 '22 02:09

Shadow