5 Replies Latest reply on Nov 25, 2006 4:14 AM by J-C jc

    Slow performance of queries and POJO mapping

    Mark van Leeuwen Newbie

      I am comparing the performance of EJB3/Hibernate with straight JDBC calls. There seems to be an issue with the EJB3 code that maps the result set to the returned list of POJOs.

      In a test of 20 threads each selecting 5000 rows, I am finding that EJB3 is about 3 times slower than the JDBC code (overall 4000 rows/sec as against 13000 rows/sec).

      To exclude the underlying query being the cause, I switched to using em.createNativeQuery(sql,class) so that the exact same query was executed as with JDBC. This ran just as slow as createQuery.

      I then tested using em.createNativeQuery(sql), ie without the POJO mapping, and the performance was > 10000 rows/sec.

      So my conclusion is that the bottleneck is with the mapping of the result set to the list of POJOs, or perhaps with the caching of the POJOs in EntityManager (?)

      Can anyone confirm this issue or suggest improvements I can make?

      I am running:
      JBoss 4.0.5.GA
      Hibernate EntityManager 3.2.0.CR2
      Hibernate Annotations 3.2.0.CR2

      Thanks