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)
 Question about indexed views

Author  Topic 

ferrethouse
Constraint Violating Yak Guru

352 Posts

Posted - 2012-12-05 : 11:23:00
In Oracle you can specify an interval for materialized views to be refreshed. In SQL Server they get refreshed when a base table is updated. That means that you don't effectively get a performance gain if you create an indexed view containing a table that is updated often. For the reports in question I don't care if the data is a bit stale. So I'd like to instruct the indexed view to only update hourly. But that doesn't seem possible. It seems to really limit the usefulness of indexed views when compared to materialized view in Oracle. Am I wrong about this or is there a way to accomplish this in SQL Server?

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-12-05 : 11:39:46
The idea is that the indexed view has an index to access the data - it's not meant to allow viewing of historic data (which would probably mean using the transaction log).
Why not create a scheduled job that refreshes the data that you need periodically - or maybe just address the issue that causes the update to be a problem - maybe use a snapshot?

==========================================
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 -