X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id AAC8A52D45 for ; Tue, 29 Mar 2005 03:53:15 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 65360-05 for ; Tue, 29 Mar 2005 02:53:07 +0000 (GMT) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by svr1.postgresql.org (Postfix) with ESMTP id 0DCF8534C5 for ; Tue, 29 Mar 2005 03:53:06 +0100 (BST) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr4.postgresql.org (Postfix) with SMTP id 683D75AF5D0 for ; Tue, 29 Mar 2005 02:53:08 +0000 (GMT) Received: (qmail 26198 invoked by uid 1112); 29 Mar 2005 02:52:36 -0000 Date: Mon, 28 Mar 2005 21:52:36 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Dave Held Cc: pgsql-performance@postgresql.org Subject: Re: JDBC best practice In-Reply-To: <49E94D0CFCD4DB43AFBA928DDD20C8F90261848E@asg002.asg.local> Message-ID: References: <49E94D0CFCD4DB43AFBA928DDD20C8F90261848E@asg002.asg.local> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/622 X-Sequence-Number: 11327 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