Stored Procedure or Computed Column

This is a question of what is the best practice and best performance.

I have inherited a database that contains data for turbine engines.  I have found 20 data points that are calculated from several fields from the turbine.  The way it was done in the past is a view was create to pull data for some turbines and calculate some of the 20 data point.  Then other views for the same turbines but different data point and then other views for different turbines and data point.  So the same equations are used over and over.

I want to consolidate all of the equations (20 data point) into one place.  My debate is either creating a user function that will do all 20 calculations or creating them as computed columns in the table.  With a function it would calculate all 20 for each turbine even thou I might only need 2 or 3 for a view.  But as a computed column it would only calculate the columns the view pulled.

January 30th, 2015 6:15pm

Is it the same calculation on all of the data points? If so why not just create a function and pass in the data for a single point and use the function as many time as necessary?
Free Windows Admin Tool Kit Click here and download it now
January 30th, 2015 7:14pm

I wish they were all the same but each of the 20 data points has its on equation and some also have decision tree also to determine the correct equation to use.  Based on thinks like altitude, Air Temp and Fuel type...  These fields are updated quite often.  But only every few months is a new record added to the table Part of why I am considering Computed Columns.
January 31st, 2015 12:10am

>My debate is either creating a user function that will do all 20 calculations or creating them as computed columns in the table. 

I vote for UDF.

Free Windows Admin Tool Kit Click here and download it now
January 31st, 2015 7:31pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics