View Single Post
Old 10-06-2004, 06:28 AM   #4 (permalink)
technobard
Centurion Nova Prime
 
technobard's Avatar
 
Join Date: May 2002
Location: Oak Park, IL (USA)
Posts: 285
technobard is on a distinguished road
Re: Nested subquery within the Select clause

Quote:
Originally posted by jsze
I know that instead of writing like this I can just join the tables in the where clause, but when it comes to tables with tens of thousands of records, this statement has reduced the retrieval time significantly.
Hey, Jsze. I'm glad your problem is resolved. The statement above bothers me though. Have you (or your dba) analyzed the tables? This seems very odd, even if the statistics are missing and the query is defaulting to "rule-based". As long as an index exists on the join column(s) of each table, I wouldn't expect to see a difference in execution plan. Of course if an index doesn't exist on the join column(s), it might make a little more sense to me. It's possible that by writing the query with a nested subquery, you're forcing the driving table and picking the "correct one".

I know this isn't your original issue, but if you have the time, it might be worth resolving this weird behavior.
__________________
It takes 2 points to draw a straight line, but at least 3 points to draw a conclusion.
technobard is offline   Reply With Quote