Reputation: 125
I have a question about persisted computed columns versus actual (normal) column.
I thought that the usage of computed columns was mainly to not physically store the values. But when it's persisted, what are the pros and cons versus a normal column in a table?
Upvotes: 2
Views: 2083
Reputation: 311338
You can think of persisted computed columns as computed columns with a cache that saves you the resources to compute the result every time you query it.
The main advantage over normal columns is that you don't need to manage them yourself (after the initial definition). With a normal column, you'd have to make sure its value is properly calculated on each insert or update, and make sure it can't be directly updated itself. With a persisted calculated column, the database does the heavy lifting for you.
Upvotes: 5