X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id BACFC9DC85B for ; Mon, 16 Jan 2006 13:51:56 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99536-06 for ; Mon, 16 Jan 2006 13:51:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 989A59DC82A for ; Mon, 16 Jan 2006 13:51:50 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id k0GHplxc009767; Mon, 16 Jan 2006 12:51:47 -0500 (EST) To: Alessandro Baretta cc: pgsql-performance@postgresql.org Subject: Re: Suspending SELECTs In-reply-to: <43CB71AC.20203@barettadeit.com> References: <43CB71AC.20203@barettadeit.com> Comments: In-reply-to Alessandro Baretta message dated "Mon, 16 Jan 2006 11:13:00 +0100" Date: Mon, 16 Jan 2006 12:51:47 -0500 Message-ID: <9766.1137433907@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.089 required=5 tests=[AWL=0.089] X-Spam-Score: 0.089 X-Spam-Level: X-Archive-Number: 200601/203 X-Sequence-Number: 16681 Alessandro Baretta writes: > I am aware that what I am dreaming of is already available through > cursors, but in a web application, cursors are bad boys, and should be > avoided. What I would like to be able to do is to plan a query and run > the plan to retreive a limited number of rows as well as the > executor's state. This way, the burden of maintaining the cursor "on > hold", between activations of the web resource which uses it, is > transferred from the DBMS to the web application server, This is a pipe dream, I'm afraid, as the state of a cursor does not consist exclusively of bits that can be sent somewhere else and then retrieved. There are also locks to worry about, as well as the open transaction itself, and these must stay alive inside the DBMS because they affect the behavior of other transactions. As an example, once the cursor's originating transaction closes, there is nothing to stop other transactions from modifying or removing rows it would have read. regards, tom lane