开发者

CTE vs View Performance in SQL Server

Which one is faster :

  1. query from a cte
  2. query from a view

(in Complex Queries). I have a complex query and i have anothe开发者_高级运维r complex query from the first one.Is it faster to create a view for the first complex query and query from the view or use cte?


A view is a permanent object and the results can be indexed, while a CTE is temporary and created only when used so less flexible. It will be more efficient to break apart your complex query into indexed views than into CTE's. It will be most efficient to ensure all of the tables are properly indexed, which will probably do more for performance than worrying about views vs. CTE's.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜