Ayende @ Rahien

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

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 10 | Comments: 37

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())
{
	s.CreateCriteria<User>()
		.Add(Restrictions.NaturalId()
			.Set("Username", "Ayende"))
		.SetCacheable(true)
		.UniqueResult();

	tx.Commit();
}

using (var s = sf.OpenSession())
using (var tx = s.BeginTransaction())
{
	s.CreateCriteria<User>()
		.Add(Restrictions.NaturalId()
			.Set("Username", "Ayende"))
		.SetCacheable(true)
		.UniqueResult();

	tx.Commit();
}

Here is what NH Prof gave me:

image

And here is what I got from SQL Profiler:

image

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

Comments

cowgaR

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

Nathan

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.

Arielr

:)

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

Set
Set

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.

ChrisB

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.

Gareth

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.

Stephen

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

tawani

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

ChrisB

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.

FUTURE POSTS

  1. Production postmortem: The case of the memory eater and high load - 8 hours from now
  2. Production postmortem: The case of the lying configuration file - about one day from now
  3. Production postmortem: The industry at large - 2 days from now
  4. The insidious cost of allocations - 3 days from now
  5. Find the bug: The concurrent memory buster - 4 days from now

And 4 more posts are pending...

There are posts all the way to Sep 10, 2015

RECENT SERIES

  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    14 Aug 2015 - The case of the man in the middle
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats