On Wed, 2006-05-10 at 10:41, Thomas Vatter wrote: > Scott Marlowe wrote: > > What happens if you do this by declaring it as a cursor and then > > fetching the first row? > > > > I do executeQuery(), for the resultSet I do next() and return one row, > but wait, I have to review the logic in this area, I can tell you > tomorrow A good short test is to run explain analyze on the query from the psql command line. If it shows an execution time of significantly less than what you get from you application, then it is likely that the real problem is that your application is receiving the whole result set via libpq and waiting for that. A cursor will solve that problem.