I've done quite a bit of investigating trying to work out the root cause. Initially I thought it might be the connection pool, so I switched from using C3P0 to DBCP, but that made no noticeable difference. I also adjusted the JDBC connection to work from the connection pool and use a proper transaction for the query. This slowed the JDBC code down a bit, but there was still a big gap.
The best I can make out, having done some profiling, is that the hydrating of objects from the database is really causing a significant performance cost which is proportional to the rows retrieved. I guess this is to be expected given the complexity of the problem of mapping between a relational database and an object model.
One useful performance improvement was to mark the transaction as read-only when performing the queries. This seemed to save about .5 m/s.
No comments:
Post a Comment