We have a (large) SELECT
query, that can take ~30 seconds to run. I am told that when placed in a view, it takes less than 5 seconds to run.
My assumption is that SQL Server caches query plans for queries that don't change, so why the massive improvement in performance here?
Just to be clear, this really is just a case of taking something like:
select * from table /* Lots of joins, where clauses */
and making it a view:
create view myfirstview as select * from table /* Lots of joins, most of the where clauses */
select * from myfirstview where /* The rest of the where clauses (i.e. the ones that can change) */