We have been using MySQL 5.6 on Amazon Aurora RDS but are now forced to upgrade to a higher version due to end of life.
We noticed that MySQL 5.7 and 8 were not performing as well as 5.6. For some of the data, the query optimiser was not choosing the best query plan (ie. choosing table scans over index scans or not choosing plans same as 5.6). Even if a query plan same as 5.6 was chosen by the optimiser, the queries were a bit slow.
On spending sometime searching for a solution, we were able to achieve performance similar to MySQL 5.6 by turning off new flags introduced in optimizer_switch in higher versions of MySQL thereby aligning the flags with that in 5.6.
For 5.7
--optimizer-switch=duplicateweedout=off,condition_fanout_filter=off,derived_merge=off
For 8
--optimizer-switch=duplicateweedout=off,condition_fanout_filter=off,derived_merge=off,use_invisible_indexes=off,skip_scan=off,hash_join=off,subquery_to_derived=off,prefer_ordering_index=off,hypergraph_optimizer=off,derived_condition_pushdown=off
Does aligning the optimiser flags in this way make mysql 5.7/8 behave same as mysql 5.6? Also, is this recommended?