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,125 | Comments: 45,486

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.


  1. The design of RavenDB 4.0: Physically segregating collections - 18 hours from now
  2. RavenDB 3.5 Whirlwind tour: I need to be free to explore my data - about one day from now
  3. RavenDB 3.5 whirl wind tour: I'll have the 3+1 goodies to go, please - 5 days from now
  4. The design of RavenDB 4.0: Voron has a one track mind - 6 days from now
  5. RavenDB 3.5 whirl wind tour: Digging deep into the internals - 7 days from now

And 12 more posts are pending...

There are posts all the way to May 30, 2016


  1. The design of RavenDB 4.0 (14):
    03 May 2016 - Making Lucene reliable
  2. RavenDB 3.5 whirl wind tour (14):
    04 May 2016 - I’ll find who is taking my I/O bandwidth and they SHALL pay
  3. Tasks for the new comer (2):
    15 Apr 2016 - Quartz.NET with RavenDB
  4. Code through the looking glass (5):
    18 Mar 2016 - And a linear search to rule them
  5. Find the bug (8):
    29 Feb 2016 - When you can't rely on your own identity
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats