In an attempt to limit the number of connections that Nhibernate opens 
against our database I have run into a problem regarding the start of a 
transaction.

We run Nhibernate 3.3 in a web-application, session-factory is created at 
application start up and on a new request we open a new session and starts 
a transaction. When the request ends we commit/rollback the transaction and 
disposes the session. My understanding was that calling BeginTransaction 
wouldn´t really start a transaction until it had something to run against 
the database, unfortunately that isn´t the case. Looking at the mysql log i 
can see that when BeginTransaction is called "SET SESSION TRANSACTION.... 
BEGIN" is directly sent to the database. 

I did a little test with second level cache enabled
1. Load an entity to get it into the cache
2. Create 100 threads and let them all request the same object.

The result was 100 open connections against the database, one meaningful 
query against the db that loaded the actual object and 100 queries that 
more or less was just begin/commit without any actual queries. This seems 
very inefficient, everything is in our cache so the database shouldn´t need 
to be bothered at all except for the first query.

Is this the intended behavior? If yes do you have any recommendations to 
avoid this bottleneck?  

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/d/optout.

Reply via email to