NH Prof New FeatureThe Query Cache
Okay, I said it is not there yet, but I got annoyed by the lack of this feature, and I really had to make this work.
That one was a pretty tough one. It required me to make some minor modifications to NHiberante, as a result, this feature works with NHbierante r3976 or up only. What this means is that if you want to use this feature, you have to get it from the trunk.
This is the only feature in NH Prof that requires the trunk.
In this feature, we can see that we detect a cached query, and are able to display it properly.:
I am not sure how I should treat this for the purpose of analysis. Should this be grouped with the actual query? Should this be a separate entry?
Anyway, just for kicks, here is the test for the feature:
[TestFixture] public class CachingTestFixture : IntegrationTestBase { [Test] public void CanDetectCachedQueries() { ExecuteScenarioInDifferentAppDomain<UsingCacheQueries>(); var array = observer.Model.Sessions[2].Statements.OfType<StatementModel>() .ToArray(); Assert.AreEqual(@"Cached query: SELECT this_.Id as Id7_0_, this_.Title as Title7_0_, this_.Subtitle as Subtitle7_0_, this_.AllowsComments as AllowsCo4_7_0_, this_.CreatedAt as CreatedAt7_0_ FROM Blogs this_ WHERE this_.Title = 'The lazy blog' /* @p0 */ and this_.Id = 1 /* @p1 */ ", array[0].Text); Assert.AreEqual(@"Cached query: select blog0_.Id as Id7_, blog0_.Title as Title7_, blog0_.Subtitle as Subtitle7_, blog0_.AllowsComments as AllowsCo4_7_, blog0_.CreatedAt as CreatedAt7_ from Blogs blog0_ where ( blog0_.Title = 'The lazy blog' /* @p0 */ ) and ( blog0_.Id = 1 /* @p1 */ ) ", array[2].Text); } }
As an aside, do you think that posting the tests is good? Should I just do the screen shots?
More posts in "NH Prof New Feature" series:
- (09 Dec 2010) Alert on bad ‘like’ query
- (10 Dec 2009) Filter static files
- (16 Nov 2009) Exporting Reports
- (08 Oct 2009) NHibernate Search Integration
- (19 Aug 2009) Multiple Session Factory Support
- (07 Aug 2009) Diffing Sessions
- (06 Aug 2009) Capturing DDL
- (05 Aug 2009) Detect Cross Thread Session Usage
- (22 May 2009) Detecting 2nd cache collection loads
- (15 May 2009) Error Detection
- (12 May 2009) Queries by Url
- (04 Feb 2009) View Query Results
- (18 Jan 2009) Superfluous <many-to-one> update
- (18 Jan 2009) URL tracking
- (10 Jan 2009) Detecting distributed transactions (System.Transactions)
- (06 Jan 2009) The Query Cache
- (05 Jan 2009) Query Duration
- (24 Dec 2008) Unbounded result sets
- (24 Dec 2008) Row Counts
Comments
very glad to see this feature as well as the last two that were introduced ;)
i'd leave the tests in these posts... it doesn't hurt anyone and it's interesting to at least some people
I admire your work overall, and with Castle/NHibernate in particular. However I'm not sure I like the idea of changing NHibernate solely to make a 3rd party tool happy.
Krzysztof,
Take a look at the changes, then tell me what you think.
nhibernate.svn.sourceforge.net/.../nhibernate
nhibernate.svn.sourceforge.net/.../nhibernate
They also benefit who ever is using NH without the profiler.
Very nice feature :)
I know this is shrink wrapped software, but how about drawing a feature freeze for this iteration and getting R1 out the door? Then, give us an R2 in 2-4 weeks with more features :)
By the way, I LOVE the fact that you can modify NHibernate to make a feature possible. I see this as an advantage of Open Source software. I realise there's a potential for abuse there too, especially if the modifier benefits financially from the changes.
I also think your NHProf site is looking very concise, and cool. Have you considered linking to the site on each blog post, and also stating that the tool is available for download? (I realised this already, but I want to see a link regardless).
Ayende,
It's not what I feared it would be. You're right, these changes benefit anyone using NHibernate, or at least thehy don't hurt anybody.
What I feared, was that you would start adding changes that would support NHProf, at the expense of making NHibernate less robust, harder to use, add no value for anyone else but NHProf, or hurting it overall in some other way.
Krzysztof, isn't it the way oss work in general? If you need something, you implement something.
Tuna,
Yes, but you fork it, if you are the only one that needs what you implement. Otherwise, you first make sure that the feature you implement is in sync with where the piece of software is going overall.
thinking out loud.. if I'm looking at queries for my app, I want to know that it runs the first time properly, and uses cached query for subsequent calls...
Not regarding your UI, I'd envision it in a tree view or some way of drilling down.
Would it be possible to have a timeline view of the executed queries and a relational view (same queries together, possibly different params)?
Comment preview