Skip site navigation (1) Skip section navigation (2)

Re: JDBC best practice

From: Kris Jurka <books(at)ejurka(dot)com>
To: Dave Held <dave(dot)held(at)arrayservicesgrp(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: JDBC best practice
Date: 2005-03-29 02:52:36
Message-ID: Pine.BSO.4.56.0503282134260.30526@leary.csoft.net (view raw or flat)
Thread:
Lists: pgsql-performance

On Mon, 28 Mar 2005, Dave Held wrote:

> I'm using a Postgres table as the data source for a JTable in a Java
> app.  Where rs_ is a RecordSet object.  What I'm wondering is whether
> it's better to call absolute() or relative() or next()/previous().  If
> absolute() is the slowest call, then I can cache the last row fetched
> and move relative to that.
> 
> My suspicion is that next()/previous() is much faster than absolute()
> when the record to be fetched is very near the last record fetched.  I
> haven't actually tried it, but I'd like some insight if others can
> already answer this question based on knowledge of the server side
> and/or the JDBC driver.

There are two types of ResultSets that can be returned by the JDBC driver.  
One is backed by a cursor and can only be used for TYPE_FORWARD_ONLY
ResultSets so it is not really applicable to you.  The other method
retrieves all results at once and stashes them in a Vector.  This makes
next, absolute, and relative positioning all equal cost.

Kris Jurka

In response to

pgsql-performance by date

Next:From: Karim A NassarDate: 2005-03-29 08:48:48
Subject: Re: Delete query takes exorbitant amount of time
Previous:From: Greg StarkDate: 2005-03-29 00:51:01
Subject: Re: which dual-CPU hardware/OS is fastest for PostgreSQL?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group