|
Posted by Peter on 10/02/22 11:45
From this discussion I conclude:
1. Select * in a view is not a performance issue when using a current
versions of SQL Server.
2. Select * in a view has benefits and drawbacks in a maintenance aspect.
Performance
I do not believe it is a big change Microsoft will change this behavior.
But, there is always a change.
Maintenance benefit
In the case I regular want the view to expose all columns of the table, I
don not have to name all the columns, but I can simply express what I want.
If the underlying table stucture is changed, I simple run exec
sp_refreshview and everything is ok again.
Maintenance drawback
If the underlying table structure is changed: columns are added and columns
are deleted but the count of column keeps the same, I do not get a error
message when I select the view and there is a change I get wrong results
without noticing it in time. I need to be very disciplinic to always use
sp_refreshview on all views that do a select * on the changed table.
For me, the drawback is a real issue, I like robust code. I also like
maintenance simplicity. I need to make a choice.
Thanks to all, I know what is the impact of this choice.
Unless someone has to add some new point in this discussion :-)
Navigation:
[Reply to this message]
|