We have a Table Value function which:

  1. Creates and Populates a table variable (@Temp) from a SELECT
  2. Runs two different UPDATE statement to change values on 2 different columns in @Temp
  3. Populates the table object RETURNED by the function from a different SELECT statement which includes the @Temp table variable

If we run steps 1 and 2 if run on their own don't take any longer than a few seconds to complete. Adding the 3rd step the execution time jumps to about 1 minute and 30 seconds.

Looking at the Execution Plan we are told that step 1 takes ~75%+ of the Query Cost.

I have always been under the impression that the "Query Cost (relative to batch)" indicates the execution time. However this does not appear to be true. Am I misunderstanding what this stat is telling me?

Thank you,