I run some tests, single table, surrogate ID, natural TEXT, loop of 100,000 iterations, session was not closed nor cleared nor flushed inside a loop, simple SELECT statement (by natural ID, as described in Docs).
Q: Why Hibernate can't retrieve cached Entity from first-level cache?
Bad test results with EhCache, about 15% of performance increase (should be 300%?). Database contains 10,000 records, all 'immutable'. Nothing wrong with test case: HSQLDB installed locally (see below), single thread, session opened before the loop and closed after...
I got following:
QueryCache enabled: 260 seconds
QUeryCache disabled: 290 seconds
(don't remember exactly...)
Q: Why plain SQL sent via JDBC, compiled and running, performs almost the same as QueryCache? I tested it even with Hashtable and OSCache, results are similar.
A: HSQLDB has a Very Good Cache!!!
Of course I forgot to mention network latency, and opponents may
say: we need QueryCache for remote databases!
Unfortunately network latency does not play any role for multithreaded
applications.
Consider single statement, it runs 3 ms, and latency is 30ms.
For 100,000 queries, running by 100 threads, it will be
Total: 300 sec + 30 ms
(or, probably, 200 sec + 60 ms)
- 'network latency' simply dissolves during long multiprocessing...
===========
Hibernate 3.1.3
|