MySQL Forums
Forum List  »  Performance

Re: distinct clause issue for 600000 records
Posted by: Øystein Grøvlen
Date: November 13, 2015 06:38AM

> Ra Nala : I should use Left join only why because
> i want each and every records from left table i.e
> main table: prdsl even though null records
> retrieve if the join condition is not matched from
> right table in my scenario.

No sure that holds in your case, but sometimes there will always be a match in right hand table (i.e., foreign key relationship). If so, you will not need to use LEFT to get "every record from the left table". E.g., in your query, if all values of rn.cbed refers to a valid id in bcu, LEFT can be dropped. (You can use foreign keys to ensure such relationships.)

Note also that you do not need to use LEFT JOIN "all the way" to get all rows of the left-most table. For example, this will still give all rows of table t1:

t1 LEFT JOIN (t2 JOIN t3 ON ...) ON ...

Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway

Options: ReplyQuote

Written By
Re: distinct clause issue for 600000 records
November 13, 2015 06:38AM

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.