sql-server – 使用视图时,表索引如何发挥作用?

前端之家收集整理的这篇文章主要介绍了sql-server – 使用视图时,表索引如何发挥作用?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个看法,从几个表收集数据.虽然视图本身没有索引,但任何使用视图的索引似乎都受益于具有索引的底层表.这些是否被自动使用?如果他们是你的意见创建索引的要点是什么?欢迎任何关于这个问题的推荐文章.

解决方法

是的,基础表索引被自动使用 – 一个视图完全从底层表中提取数据.

关于在视图上创建索引的好处,请参见this MS Technet article.小摘录:

Using indexes to improve query@H_404_10@ performance is not a new concept;@H_404_10@ however,indexed views provide@H_404_10@ additional performance benefits that@H_404_10@ cannot be achieved using standard@H_404_10@ indexes. Indexed views can increase@H_404_10@ query performance in the following@H_404_10@ ways:

  • Aggregations can be precomputed and stored in the index to minimize@H_404_10@ expensive computations during query execution.
  • Tables can be prejoined and the resulting data set stored.
  • Combinations of joins or aggregations can be stored.

猜你在找的MsSQL相关文章