January 28, 2013 at 12:07 am
My personal opinion is that if you're not going to persist a calculated column, write a derived table or view, instead. That way, no one can screw up and actually make queries that even try to use it effeciently. 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
January 28, 2013 at 9:22 am
Jeff Moden (1/28/2013)
My personal opinion is that if you're not going to persist a calculated column, write a derived table or view, instead. That way, no one can screw up and actually make queries that even try to use it effeciently. 😛
Typically the overhead to materialize the computed column (cc) at run time trivial. If it is, a cc has a lot of advantages, so I suggest using it as intended.
A derived table risks differing definitions in multiple queries.
A view forces people to use different queries to access the data depending on whether they need a certain cc or not. If a query needs that cc added, you have to rewrite the query just because of that.
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
January 28, 2013 at 5:06 pm
ScottPletcher (1/28/2013)
Jeff Moden (1/28/2013)
My personal opinion is that if you're not going to persist a calculated column, write a derived table or view, instead. That way, no one can screw up and actually make queries that even try to use it effeciently. 😛Typically the overhead to materialize the computed column (cc) at run time trivial. If it is, a cc has a lot of advantages, so I suggest using it as intended.
A derived table risks differing definitions in multiple queries.
A view forces people to use different queries to access the data depending on whether they need a certain cc or not. If a query needs that cc added, you have to rewrite the query just because of that.
Sorry Scott... I meant to put out the bright orange barrels, cones, and flags that warned people that sarcasm was "ON". Go back and read it again. It was dripping in sarcasm in support of the use of CC especially persisted CC. 😉
I'll try to give better warnings in the future.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 16 through 17 (of 17 total)
You must be logged in to reply to this topic. Login to reply