Reputation: 85
I am benchmarking JDBC and Hibernate (with JPA) performance and run the same queries several times in a row. I have noticed that the first query (Both with JDBC and Hibernate) runs longer than others.
I have disabled mysql cache, so i do believe it should not be mysql specific. Could it be? I also clear EntityManager between each (HQL) query.
Could someone point me why the first query takes longer than others?
Log: http://pastebin.com/fwNbqaMD
Thank you for your responses
Upvotes: 0
Views: 1114
Reputation: 1280
Following can be few possible reasons.
In either cases the first iteration will have more to do than rest.
For example, for prepared statements query plan is built for first time and cached for reuse in subsequent executions.
Upvotes: 1
Reputation: 39109
I guess because of runtime optimizations on your program.
During each run, profiling information of your code is collected, and the JIT optimizer applies optimizations.
Upvotes: 1