Hello,
Our HQL query to Postgres 8.1 was slow. 8.1's was known for slower sort performance. However, I tried to use Eclipse 3.3 with the latest Hibernate Tools 3.2.9 and the HQL Editor can run this query
select sample.barcode from Sample sample order by barcode
and get back more than 660K records in 8 or 9 seconds 1st time. If I rerun the query, it will be super fast (1 or 2 seconds) every time after. While our application doing standard (openSession, createQuery(HQL), setFirstResult(1), setMaxResult(100), Query.list, closeSession) will always run for 10 seconds or more. Even doing Query.setCacheable(true) in between createQuery and Query.setFirstResult does not change the speed.
My question is. What did HQL Editor do to speedup the query? I tried to find the source code for HQL editor in JBoss' site and found the ExecuteHQLAction that uses ConsoleConfiguration which uses HQLQueryPage. Finally HQLQueryPage actually does the standard openSession, createQuery, query, closeSession steps. It seems that there might be options/configuration that came in as local options or query parameters. Since I am not setup as a HQL Editor developer, I couldn't use the debugger to pause the editor to find out. Could some one please unveil the secret here?
Thank you!
Alvin
Hibernate version:3.2.1
Mapping documents:hibernate.cfg.xml
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:Postgres 8.1
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html