开发者

CTE vs View Performance in SQL Server

开发者 https://www.devze.com 2023-03-06 04:40 出处:网络
Which one is faster : query from a cte 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 v

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

精彩评论

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