The new statistics class in Hibernate 2.0 is a great tool to use for monitoring potential performance problems with your app. The class exposes a large number of counters and measurements. Here are some highlights of what is available:

EntityDeleteCount

EntityInsertCount

EntityLoadCount

EntityUpdateCount

QueryExecutionCount

QueryExecutionMaxTime

QueryExecutionMaxTimeQueryString

QueryCacheHitCount

ConnectCount

SessionCloseCount

SessionOpenCount

CollectionLoadCount

CollectionUpdateCount

CollectionRemoveCount

Queries

PrepareStatementCount

The statistics engine can be turned on/off dynamically with the IsStatisticsEnabled property and you can get statistics on specific entities as well.

Just to try this out I created a MonoRail filter that checks for "nhibstats" in the query parameters of the request. If the parameter is found it will turn on the nhibernate statistics, this is done before the controller action is executed. After the action as completed it will add the stats data to the PropertyBag so the view can access it.