简体   繁体   中英

Should we also create indexes on views too for performance in SQL Server?

我对编程有点陌生...所以我想知道是否需要为性能问题的视图提供索引?

Required is a very big word in SQL Server. Its not required if the underlying tables (of the view) have indexes that can be used by the query effectively. Many developers do create indexes on views because of the gain in performance. There is a price to pay in terms of storage (the same data is now stored in the original table and in the view and the space taken up by the indexes) and in maintenance of the indexes. So the answer, as usual, is it depends....

There are also extensive (not impossible but) requirements to create an indexed view - see https://technet.microsoft.com/en-us/library/aa933148%28v=sql.80%29.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM