Book Read: Pro .NET Performance

I’ve read this title several weeks ago and thinking of writing a blog post about it ever since I’ve finished it. Originally I was interested in learning something new about performance issues and resolutions in .NET, but the book managed to deliver some rather interesting and valuable content besides that. I’d say that the strongest and most useful material wasn’t about performance but CLR internals.

There were tons of information about CLR data structures and how classes and structs lied out in memory. That chapter alone worth well the price of the book. Also there was great coverage on garbage collection flavors and the concrete .NET GC implementation was explained well.

Of course performance was considered as well with some useful advice (on how to attack performance problems and how and what to measure at all), but the CLR internal parts were written and explained in a great manner, covering the latest version of .NET.

Until I find the time to read the most recent CLR via C# this book was a great refresher on the subject.


Design Common Language Runtime (CLR) table-valued and scalar functions

May include but is not limited to: assembly PERMISSION_SET, CLR vs. T-SQL, ordered vs. non-ordered

From SQL Server 2005 we have the nice feature of running managed code right inside SQL Server. This is something similar that Oracle did with Java, but much more cooler. You can think that if you can code in .NET, than T-SQL is certainly dying. This is not true, and because this objective covers the CLR vs. T-SQL topic, here’s a brief when and what:

Consider using SQL CLR when:

  • Pulling a lot of data, and executing lots of operations on it, especially string operations and the like.
  • Highly procedural code with lots of steps.
  • Having existing XPs, or accessing external resources from SQL Server.
  • Performing lots of calculations on pulled data.

T-SQL triumphs when:

  • When you pull little data over the wire, and do little processing on it.
  • You are dealing with set-based operations. T-SQL is always faster in it.

Continue reading