users@glassfish.java.net

Re: Toplink JPA Poor Performance with Join/Order By

From: <glassfish_at_javadesktop.org>
Date: Thu, 08 May 2008 07:18:11 PDT

Hello Bastian,

This post is quite old so you might already have found an answer, but I thought I'd add something if I could. The setMaxResults function in TopLink Essentials, as you've seen, might not help performance as much as you might expect from a database filter/clause such as limit. This is because LIMIT reduces the amount of records returned, where as the implementation of setMaxResults relies on the statement's setMaxRows api. In most cases, the driver will just filters the number of returned rows it returns, so they have still been processed and sent across the network. So setMaxResults will help, since it reduces the number of objects built, but bit as much.

In TopLink essentials, you can use a native query to take advantage of PostgreSQL's Limit (or Oracle's rownum filtering etc). In the full TopLink and EclipseLink, there is platform support for Oracle's rownum filtering, which could also be overriden on the PostgreSQL platform to allow for the use of LIMIT. A good post on this if you are interested can be found at:
  http://forums.oracle.com/forums/thread.jspa?threadID=590774&tstart=0

Best Regards,
Chris
[Message sent by forum member 'chris_delahunt' (chris_delahunt)]

http://forums.java.net/jive/thread.jspa?messageID=273338