Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Betr.: [eclipselink-users] Duration of a simple object query


Holger,

In the database, do you have keys for the fields you are doing the query on? The cache usage only has a purpose when using the primary key for a record. Just another tip: precede the named query name with the name of the class it is defined in (usally the POJO of the return type), that makes it easier to find the named query back.

regards,

Willem Kunkels
Java Developer

Koopman International BV
Distelweg 88
1031 HH  Amsterdam
The Netherlands
Tel.: +31 20 494 7 893
www.koopmanint.com



Holger Rieß <Holger.Riess@xxxxxxxxxxxxxxxxxx>

03-08-2009 16:01

Antwoord a.u.b. aan
EclipseLink User Discussions <eclipselink-users@xxxxxxxxxxx>

Aan
"eclipselink-users@xxxxxxxxxxx" <eclipselink-users@xxxxxxxxxxx>
Cc
Onderwerp
[eclipselink-users] Duration of a simple object query






My query
                ...
                Query query = em.createNamedQuery("findStockTableByItemNumber");
                query.setParameter("itemnumber", itemNumber);
                retStockTable = (Stocktable) query.getSingleResult();
                ...
needs about 15 ms if there is a record in the database and about 70 ms if there is no record (profiler).

The named query is ...
@NamedQuery(name = "findStockTableByItemNumber", query = "SELECT st FROM Stocktable st WHERE st.itemnumber =                  :itemnumber AND st.dataset = 'DAT' AND st.cKatalog = '001'", hints = {
                                 @QueryHint(name = QueryHints.CACHE_USAGE, value = CacheUsage.CheckCacheThenDatabase),
                                 @QueryHint(name = QueryHints.QUERY_TYPE, value = QueryType.ReadObject) }),
...

About 40% of my queries have no result - this is a great problem for the performance of my application.
There is no additional code for the handling of NoResultException.
_______________________________________________
eclipselink-users mailing list
eclipselink-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/eclipselink-users


Back to the top