Skip to main content

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

Hello,

With the setting CheckCacheThenDatabase, you are telling EclipseLink to search its cache before going to the database. As you've seen, if the object is in the cache, you will get much better performance since it avoids the database hit. But when the object isn't in the cache, the 70ms will be a combination of a full cache search, a database hit and building the object from the results. The only other option that might help is to avoid the initial cache search, using DoNotCheckCache instead. This will force all non-pk queries to go the database directly, avoiding some of the delay when the objects do not exist in the cache. Because it is a trade off, its up to your usage patterns to tell if skipping the cache check when the objects are not there is worth the cost of going to the database when the objects are in the cache.

Best Regards,
Chris


Holger Rieß wrote:
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