java - Hibernate JPA EntityManager.createQuery() performance -
i have query has 2 'in' clauses. first in clause takes around 125 values , second in clause of query takes around 21000 values. implemented using jpa criteriabuilder
.
query executes fast , return results within seconds. problem entitymanager.createquery(criteriaquery)
takes around 12-13 minutes return.
i search on so, threads related performance of query.getresultlist
. none of them discuss performance of entitymanager.createquery(criteriaquery)
. if have seen such behavior earlier, please let me know, how resolve it.
my jdk version 1.7. dependency version of javaee-api 6.0. application deployed on jboss eap 6.4. that's not concern of now, testing code using junit using entitymanager
connected actual oracle database. if require more information, kindly let me know.
a hybrid approach dynamically create query , save named query in entity manager factory.
at point becomes other named query may have been declared statically in metadata. while may seem compromise, turns out useful in few specific cases. main advantage offers if there queries not known until runtime, reissued repeatedly. once dynamic query becomes named query bear cost of processing once.
it implementation-specific whether cost paid when query registered named query, or deferred until first time executed.
a dynamic query can turned named query using
entitymanagerfactory addnamedquery()
keep informed result , luck
Comments
Post a Comment