Attention: We are retiring the ASP.NET Community Blogs. Learn more >

CLR Functions - SqlFunction attribute - DataAccess member

I have been reading through the documentation on the SqlFunction attribute.  I came across an interesting item in the documenation that I wanted to pass on, being that I am a data access kind of guy.

One of the members you can set is the DataAccess.  The two values you may set things to are DataAccessKind.None and DataAccessKind.Read.  If a function is set to DataAccessKind.None, there are some optimizations done in the way that the data provider handles and processes the function.  I just ran a quick test and I found that by setting the DataAccess to the value of DataAccessKind.None resulted in a performance improvement in my running of two versions of the same method.  These were simple results and might not hold up under additional scrutiny, but there does appear to be something there.  I would highly suggest that you take a look at this if you are developing CLR Functions.  Your mileage may vary.  Obviously, if the function needs to access data, you don't have a choice.

Here's my SqlFunction Attribute

<SqlFunction(DataAccess:=DataAccessKind.Read, IsDeterministic:=True, isprecise:=True, Name:="fnTest")>

Wally

1 Comment

Comments have been disabled for this content.