Would having a Composite Index be beneficial for something like this:
SELECT * FROM a INNER JOIN b ON(a.id=b.id)
INNER JOIN c ON(a.bar=c.id)
INNER JOIN d ON(a.foo=d.id)
Index would be:
(a.id, a.bar, a.foo)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Only the leading edge of the index would be used (
a.id), so only theINNER JOINtobwould benefit from the index… so the additional columns in the index (a.baranda.foo) are not beneficial in the sample query posted.From the MySql documentation: