I have a very complicated view, that involves many inner, left and outer join with other views and tables.
and in a certain procedure, that view is heavily used, which leads to a very slow execution, slower the bigger the data becomes.
I tried to create an index on that view, but failed to do so because the view is not schema bound.
(and I was unable to make it schema bound due to the complexity of it)
Then from the specific procedure that I’ve mentioned, I tried to copy the view into a temp table, then create an index on that temp table, which looked like:
select * into #localVwOrders from vwOrders ;
create clustered index idx on #localVwOrders (guid) ;
create index idx2 on #localVwOrders (date)
which did help a lot, (decreased the execution time from around 60 seconds to 10).
and these 10 seconds mostly are spend indexing that view. (executing the previous 2 lines)
so it’s not optimal to index the whole view on each execution of my procedure, I am looking for a way to either create a permanent index on my view vwOrders
, or an alternative way to increase it’s performance