Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,026 | Comments: 44,842

filter by tags archive

NH ProfNHibernate Profiler vs. Sql Profiler

time to read 1 min | 149 words

I recently got a question, asking why someone should pay for NH Prof if SQL profiler is available for (effectively) free?

The answer is actually very easy to answer. I run the following scenario through both NH Prof and SQL Profiler:

using (var s = sf.OpenSession())
using (var tx = s.BeginTransaction())
			.Set("Username", "Ayende"))


using (var s = sf.OpenSession())
using (var tx = s.BeginTransaction())
			.Set("Username", "Ayende"))


Here is what NH Prof gave me:


And here is what I got from SQL Profiler:


I think that I have rested my case, pretty conclusively.

More posts in "NH Prof" series:

  1. (09 Dec 2010) Alert on bad ‘like’ query
  2. (10 Dec 2009) Filter static files
  3. (16 Nov 2009) Exporting Reports
  4. (08 Oct 2009) NHibernate Search Integration
  5. (19 Aug 2009) Multiple Session Factory Support
  6. (07 Aug 2009) Diffing Sessions
  7. (06 Aug 2009) Capturing DDL
  8. (05 Aug 2009) Detect Cross Thread Session Usage
  9. (22 May 2009) Detecting 2nd cache collection loads
  10. (15 May 2009) Error Detection
  11. (12 May 2009) Queries by Url
  12. (04 Feb 2009) View Query Results
  13. (18 Jan 2009) Superfluous <many-to-one> update
  14. (18 Jan 2009) URL tracking
  15. (10 Jan 2009) Detecting distributed transactions (System.Transactions)
  16. (06 Jan 2009) The Query Cache
  17. (05 Jan 2009) Query Duration
  18. (24 Dec 2008) Unbounded result sets
  19. (24 Dec 2008) Row Counts



no to mention you need to get SQL Profiler for PostgreSQL (myfav), SQLite, MySQL...etc.

MS SQL Server isn't the only option for few of us, so another nHProfiler (multi-database support) win


Haven't tried NHProf yet, but MS SQL Profiler is truly an awful piece of software. Its definitely an absolute last resort for me to use it.



Nice. I don't need persistence in my application, but I'm now starting to wonder if I should YAGNI it anyway. :)


And here is what I got from SQL Profiler:

Come on, you can select the events you need, select the columns you want to see etc.

But then without other kind of logging, I guess there are some informations that might miss.


We have been using NHProf for several weeks now... my statement about the tool would be if you are using NHibernate then NH Prof is a must have tool if you want to be productive. Troubleshooting and performance tuning are much easier.

*We paid beta pricing for our each team member and it has already paid for itself on a single project.


At first glance I would agree with ChrisB also, but I looked a little closer and realized the difference that wasn't really highlighted in the article. I believe the key point here is that while not only does NH Prof look visually more appealing (which is self apparent), but it can also highlight the caching aspects within NH that the traditional database profiler doesn't see and so cant report! So its not the visual/readability aspect, but it is more of the whole holistic system can be profiled rather than just the raw DB access. Plus as others above have pointed out it is DB agnostic.


Uh, I use sql profiler.. it might not be that friendly looking or tell you a huge amount but it can be useful.


The point is: the second query is not seen by Sql Profiler.


Both are useful tools, but IMHO this is comaring apples and oranges. For example SQL Profiler can give things like read counts showing where you might investigate adding extra indexes, database issues. NH Prof is about watching the ORM. Checking how sql is constructed via the maps. Number of round trips. One click and you are back to visual studio looking at the calling code.

I must admit I was a little late to NHibernate land, only doing it for about a year, but I am sold. And NH Prof is a great teaching/learning tool for anybody just getting started.

Hudson Akridge

If anyone is seriously questioning NH Profiler vs Sql Profiler, they've only ever used Sql Profiler. I can't imagine anyone who's used both asking that question :)

NH profiler gives you 2nd level cache notifications (very important for performance analysis), and allows you to go all the way up the stack with where certain queries are being executed at (also very important when you get into a command pattern structure). Plus intelligent suggestions to improve performance, along with high level reporting to help you find the pain points rapidly.

And if that wasn't enough, the UI trumps Sql Profiler's hands down. The difference between a good application and a great one is often in the UI design.

Comment preview

Comments have been closed on this topic.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats