Re: Design question: Nested views and functions? Steve Jorgensen wrote:
> On Mon, 7 Mar 2005 23:11:06 +0000 (UTC), Erland Sommarskog
> <esquel@sommarskog.se> wrote:
>>One reason I'm a little skeptic to this approach, is that you develop
>>a set of views to use, programmers tend to choice the most complex and
>>versatile view, even if they need only one or two values from it. This
>>can bring in tables to the query that do not belong there, giving quite
>>an undesired overhead.
> That brings to mind a useful optimization idea. What if SQL Server could
> ignore M-1 outer joins when the results from the secondary table are not used
> ore returned? Thus, if we SELECT a subset of fields from a view, unnecessary
> parts of the view query could be skipped.
This optimization is sometimes called "RI-join-elimination" because the
rule only applies when the join cannot produce additional rows (e.g a
cartesian product).
Also unused scalar subqueries can be dropped, or joins with queries than
provable can only produce one row (such as a TOP 1 or a COUNT() over the
whole group).
Cheers
Serge
--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab |