persistence@glassfish.java.net

Re: getSingleResult() . It's very slow...

From: James Sutherland <jamesssss_at_yahoo.com>
Date: Mon, 14 Apr 2008 06:39:30 -0700 (PDT)

Your query is also dynamic, depending if your 400ms is spent in the database
or Java this maybe one of the reason if it is in Java. Instead try using a
name query that you define once, instead of re-building the JPQL each time.
The first execution of the query will still be the same because it will need
to be parsed, but subsequent executions will avoid the JPQL parsing.


MrFishKill wrote:
>
> Thanks Marina,
>
>
> I have a table with a 9000 registers and column is indexed. It's very
> small table. My database is a MySQL 5. Connection (entity mananager) is
> open only one time. Program and database are running in my local machine
> (Intel Code 2Duo). Around 400 milliseconds just in a 'gesSingleResult()'
> instruction. Look at this piece of code:
> ......
> long time1 = System.currentTimeMillis();
> o = q.getSingleResult();
> long time2 = System.currentTimeMillis();
> long dif_time = time2 - time1;
> System.out.println("Dif time:"+dif_time);
> .......
>
> Output:
>
> Dif time: 356
> Dif time: 423
> Dif time: 389
> ...
> ...
>
> Thanks in advance.
>
>


-----
---
http://wiki.eclipse.org/User:James.sutherland.oracle.com James Sutherland 
http://www.eclipse.org/eclipselink/
 EclipseLink ,  http://www.oracle.com/technology/products/ias/toplink/
TopLink 
Wiki:  http://wiki.eclipse.org/EclipseLink EclipseLink , 
http://wiki.oracle.com/page/TopLink TopLink 
Forums:  http://forums.oracle.com/forums/forum.jspa?forumID=48 TopLink , 
http://www.nabble.com/EclipseLink-f26430.html EclipseLink 
Book:  http://en.wikibooks.org/wiki/Java_Persistence Java Persistence 
-- 
View this message in context: http://www.nabble.com/getSingleResult%28%29-.-It%27s-very-slow...-tp16618446p16677665.html
Sent from the java.net - glassfish persistence mailing list archive at Nabble.com.