I run Nh-Prof on our production and found that the time to open NHibernate session, begin transaction and commit sometimes takes more than 4 seconds even there are no state/queries to database.
** I know that open transaction and commit it with no reason (no statements) is a bug.
This is what I see in Nh-Prof:
begin transaction with isolation level: Unspecified
commit transaction
Any suggestions?
Most probable reason:
the session used is "full" of objects and on Commit it checks each object if it has changed to generate an update statement. Even if nothing changed the check is costly.
You can check
session.GetSessionImplementation().PersistenceContext.EntitiesByKey.Count
to see how many objects are there.What you can do about it: