Wednesday, August 5, 2015

how to make views run faster in SQL Server

Hi I have created a VIEW and with in the view i have bunch of select queries with multiple table joins.So when i run the view it took me 45 seconds to get 100000 rows,even when i added a clustered index on the view , it took same time and also the execution plan showed it was not using the Index at all.

My manger told me to add  WITH (NOEXPAND)
SELECT * from View WITH (NOEXPAND)
--it took me 2 seconds to get 100000 rows

...

No comments:

Post a Comment

https://blog.sqlauthority.com/2009/06/27/sql-server-fix-error-17892-logon-failed-for-login-due-to-trigger-execution-changed-database-context...