Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> When you think about it, all joins are just a left join

Not really; using left joins enforces a specific table order in the query plan.

It's possible to optimally use left joins because one can either guess the optimal order (which is a bad habit, though), or can observe the query plan and emulate it.

My guess that this developer didn't trust the optimizer to do a good job at ordering, and he wanted to enforce it, but that is generally not the case with modern engines (of course, there will always be exceptions).



> that is generally not the case with modern engines (of course, there will always be exceptions)

In my experience, the exceptions are more than the straightforward queries I can write and forget, so much that SQL grammar feels like the German grammar: Here's what you use in this scenario, except [goes on to list a million exception cases most of which makes no logical sense].

This is especially true if you are doing complicated queries across products in a multi-product multi-tenant multi-team database. Writing the idiomatic query takes a few minutes, then hours of fighting against the query planner.

Going bonkers with left joins and/or CTEs usually "fixes" the "problem". I usually leave a commented-out sane version after me for the people who can do better, and not to be blamed with writing mortgage-code.

Neither German nor SQL (with any RDBMS) is my native language anyway, so I can publicly admit my struggles without feeling too embarrassed :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: