Home All Groups Group Topic Archive Search About

Creating Indexes on Views

Author
16 Feb 2006 10:34 PM
pmud
Hi,

I have a  view which uses 2 other views.I need to create an index on this
view. But one of the two other views has Union statements. Is there any way
that an index can be created on this final view ( which is made of the other
2 views)?

Thanks


--
pmud

Author
16 Feb 2006 11:19 PM
ML
Indexed views cannot reference other views, and a view definition cannot
include a UNION. More here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_06_9jnb.asp


ML

---
http://milambda.blogspot.com/
Author
16 Feb 2006 11:36 PM
pmud
Yes, I read that article, but i thought maybe someone ahs faced the same
problem as me and has a workaround for this. :(
--
pmud


Show quote
"ML" wrote:

> Indexed views cannot reference other views, and a view definition cannot
> include a UNION. More here:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/createdb/cm_8_des_06_9jnb.asp
>
>
> ML
>
> ---
> http://milambda.blogspot.com/
Author
16 Feb 2006 11:49 PM
ML
I was once in a similar situation, but found out that I could avoid it by
slightly adapting the data model. Maybe there's something else that would
help you achieve your goal, but you'd have to post DDL (and maybe some sample
data).


ML

---
http://milambda.blogspot.com/
Author
17 Feb 2006 9:19 PM
Gert-Jan Strik
I don't know your real problem (because you haven't told it), or your
experience with SQL Server. It sounds like you are asking for a kludge.

The first step would be to add index(es) to the base table(s). In many
cases this will increase performance sufficiently, and other queries
(queries that do not use your view) will also benefit from these
indexes.

If this is not enough, you can consider indexing the view. But as you
have noticed there are many limitations to that, and you need Enterprise
Edition (or always use the appropriate view hints).

Gert-Jan


pmud wrote:
Show quote
>
> Hi,
>
> I have a  view which uses 2 other views.I need to create an index on this
> view. But one of the two other views has Union statements. Is there any way
> that an index can be created on this final view ( which is made of the other
> 2 views)?
>
> Thanks
>
> --
> pmud

AddThis Social Bookmark Button