Magento + MySQL 5.7 = Slow Queries

After updating the database (MySQL 5.7) on the sites working on Magento 1.9, there were queries that were very slow. All slow requests began:

The full text of the request will be below.

The problem arose because MySQL stopped using indexes.

The complete query example:

If you execute this query with the EXPLAIN command, you will see that the indexes are not used everywhere: Range checked for each record (index map: 0x74)

Experienced to establish several options for solving this problem.

You can replace


Or, by analogy with a similar problem, add one more condition to the query:

We use the last solution. In file \app\code\core\Mage\Catalog\Helper\Category\Url\Rewrite.php find the method joinTableToEavCollection:

and add one line to it: