cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Durchholz, Joachim" <>
Subject RE: Performance question
Date Wed, 25 Jan 2012 13:21:25 GMT
It closes the transaction, not the connection (it's ExternalTransaction.close). You fixed that
for now by putting everything into a single transaction, but I suppose it will come back to
bite you once business logic dictates many small transactions (maybe in a later project, so
this may not be relevant for you right now - it's just something to keep in mind).
There's no good reason why a getConnection from a connection pool should take up more time
than running any SQL statement.
Either the connection isn't taken from the connection pool. Which makes me suspect the connection
pool isn't active - maybe something is misconfigured.
Or Cayenne's getConnection is unreasonably slow.
It would be nice to know what actually caused the problem.
N.B. writing your own DataSource that reuses connections would be just a reinvention of connection
pooling. You don't want to do that - connection pooling is far more involved than meets the
eye; doing it well will certainly make you go over the time budget, and doing it not-so-well
is a waste of time. (The issues I'm aware of are: keeping connections open in advance to reduce
latency, which means opening connections in a separate thread and avoiding race conditions;
dealing with connection loss due to networking outages; dealing with connection loss due to
server-side time-outs after periods of inactivity; avoiding unnecessary work in a transaction
after the connection was gone; distinguishing whether to silently reestablish connection or
report back a failed connection, that despends on whether you actually had any SQL activity
after establishing the connection. There might be more.)


From: Wernke zur Borg [] 
Sent: Wednesday, January 25, 2012 10:02 AM
Subject: Re: Performance question

To give you a picture here is a screenshot of the profiler showing that one connection is
opened and closed for every query.


The question I do not understand is why does DataNode.performQueries() unconditionally close
the current connection?

Otherwise I could probably provide a custom DataSource class overriding getConnection() to
re-use connections.


  • Unnamed multipart/related (inline, None, 0 bytes)
View raw message