MySQL Forums
Forum List  »  Performance

Re: Composite index - selecting components and order
Posted by: Rick James
Date: May 08, 2013 08:45PM

> Are you saying that composite indexes with more than one item in them are a bad thing?

No, not saying composite indexes would be bad.
Rather, I am saying they may not be beneficial for that SELECT.

> I was of the impression that you wanted many items from your WHERE clause,

Many items that are tested via "=", then one more item.

> in the order they appear in the WHERE, for optimum performance

The order in the WHERE clause is irrelevant.

Max/min requires a GROUP BY (unless you just want a max/min over the whole table).

The ORDER BY may be useful after the GROUP BY.

The syntax of the SELECT statement mirrors the order in which the operations are done:
WHERE (filtering)
GROUP BY (to trigger aggregation)
HAVING (kinda like a WHERE for aggregations)
ORDER BY (sorting the final result)
LIMIT (stopping short)

> The suggestion that indexes should only have 2 items in them would make for totally different schema design choices.

I don't understand what you are saying there. The SELECT determines what indexes would be useful.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.