• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Fast querie but return is to slow, Odd behavior?

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello i was wondering about this odd behavior,
i have this jpa (Eclipselink) Query


the line listaMyObject = query.getResultList(); doesnt take more thatn 400ms while the return statment takes about 4000ms and im only returning like 50 elements,
is it because the object is to heavy?, what am i missing? any ideas would be helpfull thanks!
 
Rancher
Posts: 2759
32
Eclipse IDE Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No it's not the return. Returning just returns a reference to the list. It's not copying the contents of the list.

Does your method have annotations? Probably there is some code woven into your code that is taking time. Maybe JPA is flushing some other changes you have done in the transaction? Take a thread dump when you encounter the "freeze". Or, debug the code, and when it's frozen, hit pause button. It should tell you what exactly it;s doing when it freezes.
 
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Jayesh said is right, this issue might be because some behavior from the container due some annotation (like maybe after that method it resumed a pending transaction or sth like that)
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the only annotation present in the method is the @Override right above it. But great idea im gonna debug and pause and see whats going
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Monique wrote:the only annotation present in the method is the @Override right above it. But great idea im gonna debug and pause and see whats going



But does the class have any annotation or XML referencing that class? Which framework stack are you using?
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the class has the @Stateless annotation, im running jee ejb, with primefaces on netbeans
Ran the debug but couldnt find anything, gonna try the profiler but i dont know much about it
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Stateless, so you use EJB. DO you have any transaction annotation (the default is required, but I'm worried if you suspend it)

How did you measure this -> " the return statment takes about 4000ms" ?
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How (or where) are you measuring this? In other words, what do the 4000ms include?
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:How (or where) are you measuring this? In other words, what do the 4000ms include?



i setup something like this inside the code

and also inside the facade that is excuting the query



so i get the during the excution query time and after the return
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see, so there's nothing much else going on that might be included in the higher number.
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes! thats why im wondering about that odd behaviour
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the Glassfish is pushing that whole object to the transaction (whatever reason). Try to change the beans used by those tests to be all @Stateless (no @Stateful) and all using @TransactionAttribute(TransactionAttributeType.NEVER) in the top of the class (and also guarantee there is no other @TransactionAttribute in use than this one). This will make very stateless and no transaction. Check if there is any difference after this change.

I also notice that the snippet have a type (or maybe is related to this issue) there is "listaMyObject" and also there is "listMyObject" in the code. is that right (like it compiles and you have an instance variable )?
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry for the late reply, after adding @TransactionAttribute(TransactionAttributeType.NEVER), im getting the exception javax.ejb.EJBException: EJB cannot be invoked in global transaction , i google but couldnt find a precise answer, im gonna go trough all the transactions im doing during the loading page process, thanks a lot!


pd: the snippet is a misstype error i did while posting sorry
 
Luan Cestari
Ranch Hand
Posts: 172
Redhat Ruby C++
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Monique wrote:Sorry for the late reply, after adding @TransactionAttribute(TransactionAttributeType.NEVER), im getting the exception javax.ejb.EJBException: EJB cannot be invoked in global transaction , i google but couldnt find a precise answer, im gonna go trough all the transactions im doing during the loading page process, thanks a lot!


pd: the snippet is a misstype error i did while posting sorry



Nice. If the page is only loading stuff from DB, it shouldn't need transaction at all (it only make sense for INSERT/UPDATE). So putting this will also increase the performance (you may just need to set the right attribute for each situation, like if you have to insert sth, you can use SUPPORTS in some beans and in the exactly the bean that make the INSERT you can start the transaction (using REQUIRED), just for a example ).

For more info:
http://openejb.apache.org/transaction-annotations.html
http://docs.oracle.com/javaee/6/api/javax/ejb/TransactionAttributeType.html
 
Paul Monique
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow thanks for the input. I didn't know the importance of TransactionAttribute annotation. I'm going to check out those links, THANKS again for all the help!!


pd: Is gonna put a whole new meaning on my transactions
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic