views:

41

answers:

1

What are the limitations, unexpected pitfalls and performance traits of moving from in process C# code to SQL CLR Functions?

We currently have several data heavy processes that run very fast using in process C# Asp.net MVC project without using a db at all. Performance is very important. The application uses a static in memory cache and performs complex operations to arrive at a final result. Cache updating is a bit of a pain and we are considering moving some of these processes to SQL Server queries that would just output the final result so that less data caching is needed at the c# app level. The processes are complex and we know that moving to the database would require extensive use of SQL Server CLR functions.

We see a lot of advantages in leveraging the database, but the required use of CLR functions gives pause for a few reasons:

No Azure: SQL CLR functions are not supported by Azure,

High Testing Cost: the SQL CLR functions could be slower and testing will take significant work

Small User Base: An hour of googling reveals that use of CLR functions is somewhat uncommon which makes community support (and possible MS support) a concern.

I would love to hear from someone who has moved a C# app from in process to CLR functions.

In your answers please assume that custom SQL CLR functions are required.

+2  A: 

Your

  • Compile
  • Install
  • Test
  • Debug

Process is a lot harder with Sql Server CLR functions – I think you should automate as much of this as possible.

You may also need to get the agreement of a DBA every time you wished to update a function.

However after saying that “take your code to your data” can still be a very good option at times.

Ian Ringrose
Simple FTP deployment of a Asp.net app with no db is hard to give up. I'm thinking about the db now because we need to fine tune the data insert, update delete process and this seems like db territory. Typically, we are on dedicated boxes so we have total control except when traffic peaks force us to scale over to azure (which we currently do). I think we could use Amazon for peaking if we build our own AMI, but I don't look forward to fiddling with db build process.
Glenn
I wondered if I might try using SQL Compact with CLR for an easier deployment. An old question in the SQL CLR forums seems to say no http://social.msdn.microsoft.com/Forums/en-US/sqlnetfx/thread/7146b3ea-6c0d-499f-9176-b14d134bc5a5/
Glenn