query extremely slow after migration to mysql 5.7

后端 未结 3 828
执笔经年
执笔经年 2021-01-02 13:14

I have a MySQL database with InnoDB tables summing up over 10 ten GB of data that I want to migrate from MySQL 5.5 to MySQL 5.7. And I have a query that looks a bit like:

相关标签:
3条回答
  • 2021-01-02 13:42

    I too faced slow query execution issue after migrating to mysql 5.7 and in my case, even setting session optimizer_switch to 'derived_merge=off'; didn't help.

    Then, I followed this link: https://www.saotn.org/mysql-innodb-performance-improvement/ and the query's speed became normal.

    To be specific my change was just setting these four parameters in my.ini as described in the link:

    innodb_buffer_pool_size

    innodb_buffer_pool_instances

    innodb_write_io_threads

    innodb_read_io_threads

    0 讨论(0)
  • 2021-01-02 13:47

    As can be read in the comments, @wchiquito has suggested to look at the optimizer_switch. In here I found that the switch derived_merge could be set to off, to fix this new, and in this specific case undesired, behaviour.

    set session optimizer_switch='derived_merge=off'; fixes the problem.
    (This can also be done with set global ... or be put in the my.cnf / my.ini)

    0 讨论(0)
  • 2021-01-02 13:47

    Building and maintaining a "Summary Table" would make this query run much faster than even 1 second.

    Such a table would probably include shop_id, date, and some count.

    More on summary tables.

    0 讨论(0)
提交回复
热议问题