Here is a simple code :
Code:
int nb=16;
for (int j = 0; j < 50; j++) {
idDocs = new Integer[nb];
for (int i = 0; i < idDocs.length; i++) {
idDocs[i] = new Integer(i + 1);
}
long deb = System.currentTimeMillis();
SQLQuery query = getSession().createSQLQuery(
"select {R.*} from placedentities R where R.idDoc in (:docs) ");
query.addEntity("R", PlacedEntity.class);
query.setParameterList("docs",idDocs);
System.out.println("nb doc:"+nb
+"\ttime="+(System.currentTimeMillis()-deb));
nb*=2;
}
Thsi gives this result :
Code:
...
nb docs:64 time=16
nb docs:128 time=62
nb docs:256 time=32
nb docs:512 time=281
nb docs:1024 time=609
nb docs:2048 time=2219
nb docs:4096 time=8938
nb docs:8192 time=34140
And I stop to wait for nb docs=16384 after 6 minutes
I saw that it is method SQLQueryParser.substituteParams that takes so much time, not the query.
I prevent this by making my own query substitution
Hibernate version:3.0