Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server 2008 CLR vs T-SQL: Is there an efficiency/speed difference?

I'm a C# developer who has done some basic database work in T-SQL. However, I need to write a very complicated stored procedure, well above my T-SQL knowledge.

Will writing a stored procedure in C# using the .net CLR as part of SQL Server 2008 cause my stored procedure to be less efficient than if it were written in T-SQL? Is the difference (if any) significant? Why?

like image 955
David Pfeffer Avatar asked Jan 19 '10 23:01

David Pfeffer


1 Answers

CLR require some communication overhead (to pass data between the CLR and SQL Server)

Rule of thumb is:

  • If your logic mostly includes transformations of massive sets of data, which can be performed using set operations, then use TSQL.

  • If your logic mostly includes complex computations of relatively small amounts of data, use CLR.

With set operations much more can be done than it seems. If you post your requirements here, probably we'll be able to help.

like image 100
Quassnoi Avatar answered Sep 28 '22 16:09

Quassnoi