MySQL Forums
Forum List  »  Newbie

Re: Fast 3 Table Join
Posted by: Rick James
Date: March 22, 2012 10:01PM

> Table B has two columns (idA, idC)
That's a "many to many" relationship between the other two table. It needs
PRIMARY KEY (idA, idC)
and possibly
INDEX(idC, idA)
(depending on what your SELECTs really look like.

Why are there fewer 'relations' than there are rows in A and C? Are most of A and C not linked to each other?

This will give you 25 million rows; that takes a long time:
SELECT *
FROM A,B,C
WHERE A.idA = B.idA AND C.idC = B.idC
Do you ever really need to fetch all of them?

Options: ReplyQuote


Subject
Written By
Posted
March 21, 2012 07:57AM
March 21, 2012 08:07AM
March 21, 2012 08:08AM
March 21, 2012 08:16AM
Re: Fast 3 Table Join
March 22, 2012 10:01PM
March 23, 2012 06:04AM
March 24, 2012 09:49PM
March 24, 2012 10:04PM
March 25, 2012 05:59AM
March 26, 2012 10:54PM


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.