HighTechTalks DotNet Forums  

there seems to be some overhead between SQL Server 2005 and a CLR function written in C#. Why is this?

Dotnet Framework microsoft.public.dotnet.framework


Discuss there seems to be some overhead between SQL Server 2005 and a CLR function written in C#. Why is this? in the Dotnet Framework forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
DR
 
Posts: n/a

Default there seems to be some overhead between SQL Server 2005 and a CLR function written in C#. Why is this? - 10-27-2007 , 12:24 AM






there seems to be some overhead between SQL Server 2005 and a CLR function
written in C#. Why is this?

I have a simple wraper around System.Diagnostics.Stopwatch.GetTimestamp() :

public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static long GetTimestampF()
{
return System.Diagnostics.Stopwatch.GetTimestamp();
}
};


but if i run this it is hardly accurate. the time of getting from sql server
to a CLR function seems to be relatively slow for nanosecond calculations:

DECLARE @before bigint
DECLARE @after bigint
SET @before = dbo.GetTimestampF()
-- do something
SET @after = dbo.GetTimestampF()
SELECT @after - @before as nanoseconds

is there nyway to elimitate this overhead so that dbo.GetTimestampF()
executes as fast for TSQL as it is to call GetTimestampF() in C#?

If i call my GetTimestampF() on c# it executes fast enough for the
nanosecond results to be accurate



Reply With Quote
  #2  
Old   
Cowboy \(Gregory A. Beamer\)
 
Posts: n/a

Default Re: there seems to be some overhead between SQL Server 2005 and a CLR function written in C#. Why is this? - 10-29-2007 , 10:30 AM






Is this true everytime you call the routine, or only the first. There will
be some JIT overhead on the first call. This is why websites now have the
ability to run through all of the pages and pre-JIT compile them.

Other than that, I would have to look at the SQL docs.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
Quote:
Think outside the box!

*************************************************
"DR" <softwareengineer98037 (AT) yahoo (DOT) com> wrote

Quote:
there seems to be some overhead between SQL Server 2005 and a CLR function
written in C#. Why is this?

I have a simple wraper around System.Diagnostics.Stopwatch.GetTimestamp()
:

public partial class UserDefinedFunctions
{
[Microsoft.SqlServer.Server.SqlFunction]
public static long GetTimestampF()
{
return System.Diagnostics.Stopwatch.GetTimestamp();
}
};


but if i run this it is hardly accurate. the time of getting from sql
server to a CLR function seems to be relatively slow for nanosecond
calculations:

DECLARE @before bigint
DECLARE @after bigint
SET @before = dbo.GetTimestampF()
-- do something
SET @after = dbo.GetTimestampF()
SELECT @after - @before as nanoseconds

is there nyway to elimitate this overhead so that dbo.GetTimestampF()
executes as fast for TSQL as it is to call GetTimestampF() in C#?

If i call my GetTimestampF() on c# it executes fast enough for the
nanosecond results to be accurate




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.