Pages

Thursday, July 28, 2011

Computed column expressions in SQL

SQL table column can be defined as a computed column expression, which is not a physical column in that table, unless specifically given as PERSISTED. The value is derived from some other columns in the same table.

Why it should be persisted?

If you have to calculate the value in each time a user request for it, then it will consume more processor time. So, making it "persistent" will save data in the disk which will reduce CPU contention.

However, if there is a concern on the disk space limitations, leaving it non-persistent would be ideal.

No comments:

Post a Comment