Exceptions Usability

time to read 1 min | 161 words

I just made a small change to the EnsureMaxNumberOfQueriesPerRequestModule, when it detects that the amount of queries performed goes beyond the specified value, it would also include the queries that it detected in the exception message. Very minor change, but the affect is that I can just scroll the page and say: "Oh, I have a SELECT N+1 here", directly off the exception page.

On a side note, I am getting better at optimizing NHibernate based application, and I strongly suggest anyone using NHibernate to look at Multi Query in 1.2 (and Multi Criteria on the trunk) for those kind of things. It give you quite a bit of power.

I run into several places today that we would read & write large amount of data on a single request, and that triggered the max query limit. It took a while, but some interesting usage of both batching & multi queries dropped the database roundtrips by an order of magnitude. Nice.