I am using hibernate second-level caching with in-memory ehcache, and it is slow. I mean, not slower than SQL, but not really faster either given a fast database on an SSD. The actual speed increase is less than a factor of 2, and sometimes unnoticeable.
It seems that others had the same problem, but got no answer: http://forum.spring.io/forum/spring-projects/data/44353-hibernate-second-level-caching-slow-no-really-slow https://forum.hibernate.org/viewtopic.php?t=985913
After some profiling, it seems that hibernate always de/re-hydrates the cache elements, instead of directly storing them, which leads to this abysmal performance (over a factor of 100 compared to direct use of ehcache).
So, my questions are:
- Can hibernate store and restore the cached objects directly?
- Is there some other way to speed up the second level cache?
- Is there a relatively simple alternative mechanism for faster hibernate caching?