简体   繁体   中英

why MySql 8.0.17 Select query performance is slower than Mysql 5.7.26?

We have very basic query like

select * from Some_Table

which used to work fine in Mysql 5.7 . And same data in Mysql 8. 0 is taking some time double the time( around 2 million data). We have upgraded from 5.7 to 8.x and seeing the performance degrade. Also we tried changing the values for below system variables in my.cnf file but the issue still persists.

sort_buffer_size 
read_buffer_size 
read_rnd_buffer_size
myisam_sort_buffer_size
max_allowed_packet 
wait_timeout
interactive_timeout
connect_timeout

Any help will be great , how to make 8.x faster than or equal to 5.7x

Seems to be an unsolved bug!

I'd like to confirm that I have the same problem with MySQL 8.0.21 on my Windows developer machine (64 GB RAM, Ryzen 3900, NVE SSD) where a count of a simple table with ~ 70.000 data sets takes 22 seconds. Adding WHERE id > 0 as suggested above reduces the query time to 0.2 seconds. So there is definitely a bug in MySQL 8. Testing the same table on a much slower windows machine (Surface Pro 3) with Maria 10 DB or any online Host with MySQL 5.7 also gives instant results.

https://bugs.mysql.com/bug.php?id=97709

Here with potential patch: https://bugs.mysql.com/bug.php?id=100966

However, my Mysql 8.0.23 has still slow speed issues.


The suggested temporary "fix" for the bug is to change your MySQL query (if applicable) to use id > 0 :

SELECT COUNT(*) FROM yourtable 
WHERE id > 0

Last comment in the mysql bug thread is:

We have encountered the same issue, after some extensive test we found that setting the variable innodb_flush_method to FSYNC. The performance improves dramatically.

I have checked my DB using SHOW VARIABLES and found innodb_flush_method with value fsync , so this is definitely not the fix for the bug.

innodb_flush_log_at_timeout 1
innodb_flush_log_at_trx_commit 1
innodb_flush_method fsync
innodb_flush_neighbors 0
innodb_flush_sync ON
innodb_flushing_avg_loops 30

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM