9

I wonder whether sql server calculate views every time when someone query the views. It is because everytime I query the views, it take such a long time.

And when I tried to shorten the time by selecting only top 10 rows from the view, it takes the same amount of time. I suspect sql server need to calculate the view for the whole table even if I only want a few rows from the view, am I right?

asked Oct 26, 2011 at 6:15

1 Answer 1

6

Yes, a view is just a macro (unless indexed). The behaviour is well known.

See Tony Rogerson's article. You can see it yourself in the query plans too. The view doesn't exist on the query plan because it can't exist as a macro

Also note the "Predicate Pushing" phenomenon when you filter or TOP on views

answered Oct 26, 2011 at 6:24

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.