Create an index on SQL view with UNION operators? Will it really improve performance?

后端 未结 2 1305
逝去的感伤
逝去的感伤 2020-12-10 02:44

I am trying to create an index on the following view:

SELECT     \'Candidate\' AS Source, CandidateID AS SourceId, LastName + \', \' + FirstName AS SourceNam         


        
2条回答
  •  既然无缘
    2020-12-10 03:26

    You cannot create an index on a view that makes use of a union operator. Really no way around that, sorry!

    I would imagine you've seen this, but check out this MSDN page. It gives the requirements for indexed views and explains what they are and how they work.

    As to whether or not you'd see a performance benefit if you COULD index the view, that would depend entirely on the size of your tables. I would not expect any impact on creating separate indexed views, as I would assume that your tables are already indexed and you aren't doing any joining or logic in the view.

提交回复
热议问题