This content has been marked as final. Show 2 replies
There are a number of docs on how to profile EclipseLink to find out where time is being spent. Here is a link on overall performance:
Here is one specific to the EclipseLink profiler:
The profiler can tell you where each query is spending its time.
Please also note that you may want to turn on logging to see the SQL that actually gets generated for your JPQL query so you can see if there is a difference that might account for added time in the database statement. EclipseLink logging is described here: http://wiki.eclipse.org/EclipseLink/Examples/JPA/Logging . Remember to turn it off though for time comparisons as it will slow down the JPA query.
Please also remember that the database might be using a prepared statement for your JDBC query while have to parse the JPQL query statement the first time. Try executing the query multiple times to see how the performance changes.
109 seconds makes no sense. Even 9 seconds for a simple count query seems very odd, unless the table is extremely huge. What kind of machine/environment are you running on? Or did you mean milliseconds?
Is it the first time you have executed a query? It could be that the persistence unit is being initialized, or the JPQL parser classes may be being loaded.
Try executing the query several times to see if it is just the first time.
Also, try using a VM profiler such as JProfiler to see what is going on.