|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Compiling a view
I'm not sure if this has been discussed already - but my question is: at what point is a view on sql server2k compiled? I'm pretty sure that a view is recompiled each time it is used (actually an execution plan is recompiled), but is it compiled at any other time? Like when using alter/create view, or hitting ok/apply in Enterprise Manager when creating/changing the view.
Thanks. |
|
#2
|
||||
|
||||
|
Views are not automatically recompiled, only stored procedures are.
Views have to be recompiled whenever a change is made to the table structure. And they are recompiled when a changes has been made to the view itself. Stored Procedures on the other hand, automatically recompile, when there are changes to a tables structure. |
|
#3
|
|||
|
|||
|
This article http://builder.com.com/5100-6388-1050681.html says that a view is recompiled for every call (regardless of whether it changed):
'But SQL Server must retrieve the view definition and compile it for every call.' Anyway, I know this is splitting hairs, but, in the case when a view is altered (alter view / hitting 'apply' in enterprise manager) is the view immediately recompiled? Or does it wait until it is used? In other words, does the action of the user changing the view cause an immediate recompile, or does it recompile only when used? |
|
#4
|
||||
|
||||
|
Yes, They are recompiled when called.
But if the table structure itself changes, the view is not automatically recompiled. So if the table structure a view references is changed, the view itself must be recompiled. As far as I know, the view is recompiled both times. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Compiling a view |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|