Imagine a table with multiple columns, say, id, a, b, c, d, e. I usually select by id, however, there are multiple queries in the client app that u
SELECT in a query -- think UNION, subquery, derived table, etc -- is optimized separately. That is each might use different indexes.SELECT can use multiple indexes in what it calls "index merge". This is rarely used.EXPLAIN says it is using Index merge (intersect), then it can almost always be improved by using a composite index containing the columns used by the intersected indexes.Index merge (union) is sometimes (rarely) used for an OR. Such can perhaps be improved by rewriting the query to be the UNION of two SELECTs.