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 D83633A53AA for ; Mon, 24 Jan 2005 08:51:31 +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 67442-10 for ; Mon, 24 Jan 2005 08:51:26 +0000 (GMT) Received: from relay.ie-online.it (mercurio.ie-online.it [193.27.202.38]) by svr1.postgresql.org (Postfix) with ESMTP id 7E99F3A539B for ; Mon, 24 Jan 2005 08:51:26 +0000 (GMT) Received: from [192.168.0.95] (unknown [192.168.0.95]) by relay.ie-online.it (Postfix) with ESMTP id 0D1AA48E3E4; Mon, 24 Jan 2005 09:51:24 +0100 (CET) Message-ID: <41F4B798.60408@ie-online.it> Date: Mon, 24 Jan 2005 09:53:44 +0100 From: Daniele Bufarini User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.5) Gecko/20050103 X-Accept-Language: en-us, en, it MIME-Version: 1.0 To: Kris Jurka Cc: pgsql-jdbc@postgresql.org Subject: Re: [S] Re: Problems with non scrollable cursors References: <41F12F29.5010602@ie-online.it> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiVirus: checked by Vexira MailArmor (version: 2.0.1.16; VAE: 6.29.0.5; VDF: 6.29.0.52; host: relay.ie-online.it) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.05 tagged_above=0 required=5 tests=FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200501/225 X-Sequence-Number: 12105 Kris Jurka wrote: >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 > > Actually using the cursor multiple time is what I was thinking... In fact, I can keep an open database connection only for large result set and use a one time connection for all the others. My problem is that I cannot scroll back using a cursor... I'm wondering If I have to modify the jdbc driver or the back end or if there are other solutions, less time consuming... Daniele Bufarini -- .-----------------------------------------------------------------. | Daniele Bufarini Informazioni Editoriali I.E. S.p.A. | | software architect Via Bergonzoli 1/5 - 20127 Milano (IT)| | Tel: +3902283151 Fax: +390228315900 | | http://www.ie-online.it daniele.bufarini@ie-online.it | | There are only two truly infinite things, the universe and human| | stupidity; I am unsure of the former. - Albert Einstein | '-----------------------------------------------------------------'