Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Indexed Views related query

Author  Topic 

Kimi86
Yak Posting Veteran

79 Posts

Posted - 2012-07-27 : 08:22:53
I have to create an index on a heavy view. But as googled I found that indexed views are stored in database. But I thought Views should not occupy space that is the whole point of creating views. So my question is if there is any difference betweeen storage of indexed views and Tables in SQL Server

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-27 : 09:01:30
An indexed view materialises the view so it does use up space.
Your mistake is thinking that a view and indexed view are similar.
It's not quite the same as a table as any query on an underlying table can use the view instead for performance.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Kimi86
Yak Posting Veteran

79 Posts

Posted - 2012-07-27 : 09:46:16
Sorry i am still not clear.

Option 1:
I copy all data from that view (without index) in a table and create an an index on this table.

Option 2:
I create the index on the view and create an indexed view.

Whats the difference between the indexed table and the indexed view in this case in terms of space and performance. Are they the same??
Go to Top of Page

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-07-27 : 10:13:08
In terms of space it should be similar.
In terms of performance - you would need to maintain the new table and queries wouldn't use the new table unless referenced explicitely.

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -