MySQL 5.5 to 5.7 stopped using indexes
I have Magento 1.9.2.1. And it works successfully on Apache2 and MySQL 5.5.
I tried to migrate it to another server and used NGINX and MySQL 5.7 for it.
But the site started very slowly (12 seconds versus 2). After hours of debugging, I found that there is a problem in one request:
SELECT
`main_table`.`entity_id`,
`main_table`.`name`,
`main_table`.`path`,
`main_table`.`is_active`,
`main_table`.`is_anchor`,
`url_rewrite`.`request_path`
FROM
`catalog_category_flat_store_1` AS `main_table`
LEFT JOIN
`core_url_rewrite` AS `url_rewrite` ON
`url_rewrite`.`category_id` = `main_table`.`entity_id` AND
`url_rewrite`.`is_system` = 1 AND
`url_rewrite`.`store_id` = 1 AND
`url_rewrite`.`id_path` LIKE 'category/%'
WHERE
(`main_table`.`include_in_menu` = '1') AND
(`main_table`.`is_active` = '1') AND
(`main_table`.`path` like '1/2/%')
ORDER BY
`main_table`.`position` ASC;
And from the explanation I found that the index is not being used. On an old MySQL 5.5 server, explain the command showing the index in use. As soon as I force the index to be used - the new server replies in 0.01s instead of 10s. But I think it is not recommended to change the magenta source files.
Is there a way to make MySQL 5.7 work the same as 5.5 in index selection?
source to share
Unfortunately only MySQL downgrades from 5.7 to 5.5 a fixed similar issue for me. Magento sql query has no index
source to share