X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 179603A4BF2 for ; Fri, 21 Jan 2005 19:55:04 +0000 (GMT) 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 93592-04 for ; Fri, 21 Jan 2005 19:54:55 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id 936193A4CA1 for ; Fri, 21 Jan 2005 19:53:44 +0000 (GMT) Received: (qmail 25584 invoked by uid 1112); 21 Jan 2005 19:57:03 -0000 Date: Fri, 21 Jan 2005 14:57:03 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Daniele Bufarini Cc: pgsql-jdbc@postgresql.org Subject: Re: Problems with non scrollable cursors In-Reply-To: <41F12F29.5010602@ie-online.it> Message-ID: References: <41F12F29.5010602@ie-online.it> 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.009 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/209 X-Sequence-Number: 12089 On Fri, 21 Jan 2005, Daniele Bufarini wrote: > I'm developing a web application. I haveto know exactly how many pages I > have and I have to allow the user to jump to a specific page( this is > where I used limit and offset): I know that this solution is VERY slow > and I tried to use cursors.... BUT (from PostgreSQL docs): > " The Statement must be created with a ResultSet type of > ResultSet.TYPE_FORWARD_ONLY. This is the default, so no code will need > to be rewritten to take advantage of this, but it also means that you > cannot scroll backwards or otherwise jump around in the ResultSet." !!! > So I cannot, for example, use the ResultSet.absolute() to jump back in > the result set! You are kind of out of luck. The only way a scrollable cursor will be faster than a limit/offset is if you use it multiple times. To use it multiple times you need to keep this cursor open across numerous page requests. This is a complicated piece of backend state because it may take up significant server resources and then there is the business of "finding" this cursor again when the user comes back. Are you really going to try and keep an open database connection for every user? Not in any web app that I know. Kris Jurka