MySQL Forums
Forum List  »  InnoDB

LEFT_JOIN_optimization work on innodb(mysql4.1.19)?
Posted by: fogee fogee
Date: July 16, 2005 01:14AM

i find in manual:

Starting from 4.0.14, MySQL does the following LEFT JOIN optimization: If the WHERE condition is always false for the generated NULL row, the LEFT JOIN is changed to a normal join.

For example, the WHERE clause would be false in the following query if t2.column1 would be NULL:

SELECT * FROM t1 LEFT JOIN t2 ON (column1) WHERE t2.column2=5;

Therefore, it's safe to convert the query to a normal join:

SELECT * FROM t1,t2 WHERE t2.column2=5 AND t1.column1=t2.column1;



is work on innodb(mysql4.1.19)?my query:

1.use left join:
select seeker0_.userId from seeker seeker0_,
intent intent4_
left outer join intentindustrys industrys7_ on intent4_.intentId=industrys7_.intentId
left outer join industry industry8_ on industrys7_.industryId=industry8_.industryId
where (1=1 )and(seeker0_.mtime>='2004-07-16 01:42:03' )
and((industry8_.levelCode like '00000016%' ))
and(intent4_.seekerId=seeker0_.userId ) limit 26;

2.normal join
select seeker0_.userId from seeker seeker0_,
intent intent4_,intentindustrys intdustrys,industry industry8_
where (1=1 )and(seeker0_.mtime>='2004-07-16 01:42:03' )
and(intent4_.seekerId=seeker0_.userId )
and intdustrys.intentId = intent4_.intentId
and industry8_.industryId = intdustrys.industryId
and((industry8_.levelCode like '00000016%' ))
limit 26;

the second use 0.02s,the first use 0.6s

Options: ReplyQuote


Subject
Views
Written By
Posted
LEFT_JOIN_optimization work on innodb(mysql4.1.19)?
3205
July 16, 2005 01:14AM


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.