Showing posts with label joins. Show all posts
Showing posts with label joins. Show all posts

Monday, March 26, 2012

Right/left outer joins & performance

Other than being much less readable, is there a downside to combining left and right outer joins in the same SELECT? I'm reviewing some generally poor code done by a contractor and it's peppered with queries with both left and right joins. I've always thought it was just a semantic difference, but I was just wondering if, other than readability, there were any performance issues.

Thanks,
PeteLeft and right outer joins do different things. Whether the Sql is running the correct logic for the situation is what is most important. It's certainly possible that the query performance could be enhanced, particularly once multiple joins are involved but that is secondary do whether the queries are returning what is required.

I would try to understand what each query is trying to do and based on that think about alternatives that may simpify it and/or improve performance.sql

Friday, March 23, 2012

Wednesday, March 21, 2012

Rewriting left joins

Hello,

I am working on a query that has 11 left join statements, some are hitting against reference data that has a small amount of records, whereas others not so small. From a performance standpoint, should I look at rewriting this query, and how would I do so? What is an alternative to left joins; any examples anyone has?

Thanks.

The alternative to a join is a subquery. Google "Join or subquery" for information in which performs better. Loads of different opinions, but it would appear that only testingyourquery inyourenvironment will produce the right answer foryou.|||

bmains:

From a performance standpoint, should I look at rewriting this query

I would say that it depends on whether your query is performing poorly or not. I wouldn't touch it if it isn't broken