Groups | Blog | Home
all groups > sql server programming > january 2004 >

sql server programming : Views Efficiency


James Hokes
1/20/2004 5:40:12 PM
Andrew,

None generally, although I am seeing some bizarre behavior in SQL2000 with
using certain types of UNION views, where the optimizer is making very
foolish assumptions about which indices to use. The best practice, as
always, is to try it out, and check out the execution plan(s) for various
queries over a representative workload script.

James Hokes

[quoted text, click to view]

Andrew Banks
1/20/2004 10:18:50 PM
How efficient is ti to use join views in a database?

I'm developing an e-commerce system and using join views to join the
product, product category and product review tables and wondering if this
would have any adverse effect on performance.

Thanks in advance

Erland Sommarskog
1/20/2004 10:42:46 PM
Andrew Banks (banksy@nojunkblueyonder.co.uk) writes:
[quoted text, click to view]

Views are essentially macros. That is, there are no query plans
associated with views, so views or direct SELECT statements does
not really make much difference.

There is one exception, and that is you create a clustered index
on the view. In this case the view is materialized, and SELECT:s
against the view are likely to be faster than SELECTs against the
table. The price you pay is that updates takes longer time.



--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
Andrew Banks
1/20/2004 10:44:13 PM
Thanks Erland

[quoted text, click to view]

Delbert Glass
1/21/2004 11:33:14 AM
FYI

Sometimes when a view is used more then once in a query,
a better plan is generated for the query then when no view is used.

Seems to me, the query optimizer is a bit limited/lazy about realizing
various parts of query are the same. But at least one can use a view
to help the query optimizer come to that realization; upon which,
the query optimizer will consider taking advantage of that fact.

Bye,
Delbert Glass

[quoted text, click to view]

AddThis Social Bookmark Button