Monday, June 15, 2009

do you really need that left join?

I've been working with mySql and ruby on rails developers for the last several years and found that the generated code seems to like left joins. Something like

select * from foo
left join bar on foo.id=bar.foo_id

In most cases I've found they rarely need the left join and a simple eqi-join will work as well and significantly reduce the noise in the mysql slow query log. Check those slow queries and if you see lots of left joins and left outer joins have a conversation with your friendly developer.

No comments:

Post a Comment