Why is this mySQL query extremely slow?
问题 Given is a mySQL table named "orders_products" with the following relevant fields: products_id orders_id Both fields are indexed. I am running the following query: SELECT products_id, count( products_id ) AS counter FROM orders_products WHERE orders_id IN ( SELECT DISTINCT orders_id FROM orders_products WHERE products_id = 85094 ) AND products_id != 85094 GROUP BY products_id ORDER BY counter DESC LIMIT 4 This query takes extremely long, around 20 seconds. The database is not very busy