Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Basically I have two scalar UDFs that output the same data, one that uses a cursor and one that uses a recursive CTE. I want to determine which one should be used and discard the other; I'd prefer to make this decision based on actual performance numbers. I'm also curious how much of a difference there is between the two.

How can I benchmark the performance of these UDFs to figure out which one is faster?

share|improve this question
'Good/Best' are considered to be subjective questions, that is why I re-framed your question. – CoderHawk Jan 20 '11 at 9:09
In this particular case, its not about the UDF; whether CTE or Cursor causing the performance. You are free to post both UDF's definition here, so that experts can look at it and suggest work arounds. – CoderHawk Jan 20 '11 at 9:11
@Sandy, posting the udf definitions sounds like it would lead to qualitative analysis, which is definitely not what I'm asking for. I want to base this decision on the cold hard truth of raw performance numbers only. – Factor Mystic Jan 20 '11 at 15:35

The SQL Profiler, execution plan, IO/Cpu statistics are your best friend at checking the performance of your code. You will see if there are any differences in performance between the 2 versions of functions.

In this question - Tuning exercises - you can find some basic and advanced references about tuning.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.