0 Replies Latest reply on Jan 12, 2007 9:00 AM by Ståle Pedersen

    EntityManager.find(Class,Object) performance

    Ståle Pedersen Newbie

      hi, ive been working on a ejb3 application that need to cache as much as possible. queries are cached manually by storing the result (only the primary keys) in jbosscache (the same cache as the entity beans).
      when that query is called again we fetch the id's from cache and for each id we just call EntityManager.find(Class, id), most of the objects are loaded into the cache at this point so there are zero db calls. this works very well, but it doesnt perform as good as we hoped.
      a resultset of 1000 objects take 200ms (when we call EntityManager.find(...) for each id), but if we call the cache directly for each entry it takes about 20ms in total (but we really do not want to do this).
      if we do the query "normally" (without any caching) it performs better than if we call EntityManager.find(...) for each entry, about 50-80ms.
      are there any way to speed up the EntityManager.find(..) call?
      IsolationLevel is none and CacheMode is local.

      i understand that the easy solution is to not cache queries, but if we dont the database will crumble down in notime and i would rather not use the hibernate query cache since that would eat up cachememory very fast (since we also have entity cache).

      any input would be highly appreciated..