On Feb 26, 7:41*am, paankh...@googlemail.com wrote:
> *Hi,
>
> I have a task at hand to reduce the time taken for search query to
> execute. The query fetches records which will have to sorted by
> degrees away from the logged in user. I have a function which
> calculates the degrees, but using this in the search query slows the
> execution and takes about 10 secs to complete which is unacceptable.
>
> Please advice. Your help is much appreciated
>
> For more details plz see:
>
> http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=97021
>
> Thanks
> Isfaar
Hi Isfaar,
Would it be possible for you to post your query here along with udf
definition. When a scalar UDF is invoked for each row in a query, it
can degrade the performance i.e. for each row you incur UDF invocation
cost. An inline expression might be faster than UDF in this case.
Depending on your SQL Server version, you might have to adopt
different approach. If you are on SQL Server 2005, then cross apply
operator in conjuction with inline table function will do the trick
for you. Inline table function behaves differently than scalar
function.
If you are on SQL Server 2000, a precisely written subquery might do
the trick.
HTH,
Najm