Mysql – How to improve performance for read only innodb MySQL Database

concurrencyMySQLmysql-5.7

I have a particular task which is to maximize the concurrent performance. There is only one particular type of query, which is

select * from table where col1 between ? and ? and col2 between ? and ?

I have created a composite index for (col1, col2). The table is about 20G in size and 100 million rows

However, even in peak concurrent requests, the CPU utilization for MySQL is only 30%. I have tried various techniques like increase max_connections, innodb_buffer_pool_instances but none of them are working.

How to maximize the configuration so that it can perform such read-only query to extreme?

Best Answer

Can't optimize it without some serious surgery. Think of it as a "bounding box" as discussed in http://mysql.rjweb.org/doc.php/find_nearest_in_mysql

It discusses 5 ways of doing "find nearest". You are on the second-worst, and probably do not have the best indexes for that. Then it moves on to 3 faster ways to run the query, but they require non-trivial effort. But the speedup is quite significant.

As for concurrency, those algorithms provide performance by decreasing the I/O and CPU. This allows for more concurrency and even lower CPU usage.