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 626619DC99B for ; Tue, 17 Jan 2006 16:19:37 -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 92940-01 for ; Tue, 17 Jan 2006 16:19:37 -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 4B8CE9DC993 for ; Tue, 17 Jan 2006 16:19:32 -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 k0HKJVgB021017; Tue, 17 Jan 2006 15:19:31 -0500 (EST) To: Alessandro Baretta cc: pgsql-performance@postgresql.org Subject: Re: Suspending SELECTs In-reply-to: <43CD4BD0.9090807@barettadeit.com> References: <43CB71AC.20203@barettadeit.com> <9766.1137433907@sss.pgh.pa.us> <43CD4BD0.9090807@barettadeit.com> Comments: In-reply-to Alessandro Baretta message dated "Tue, 17 Jan 2006 20:56:00 +0100" Date: Tue, 17 Jan 2006 15:19:31 -0500 Message-ID: <21016.1137529171@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.09 required=5 tests=[AWL=0.090] X-Spam-Score: 0.09 X-Spam-Level: X-Archive-Number: 200601/260 X-Sequence-Number: 16738 Alessandro Baretta writes: > * When the cursor state is pushed back to the backend, no new > transaction is instantiated, but the XID of the original transaction > is reused. In the MVCC system, this allows us to achieve a perfectly > consistent view of the database at the instant the original > transaction started, unless a VACUUM command has been executed in the > meantime, in which case I would lose track of tuples which would have > been live in the context of the original transaction, but have been > updated or deleted and later vacuumed; however, this does not bother > me at all. > Is this not a viable solution? No. I'm not interested in "solutions" that can be translated as "you may or may not get the right answer, and there's no way even to know whether you did or not". That might be acceptable for your particular application but you certainly can't argue that it's of general usefulness. Also, I can't accept the concept of pushing the entire execution engine state out to the client and then back again; that state is large enough that doing so for every few dozen rows would yield incredibly bad performance. (In most scenarios I think it'd be just as efficient for the client to pull the whole cursor output at the start and page through it for itself.) Worse yet: this would represent a security hole large enough to wheel West Virginia through. We'd have no reasonable way to validate the data the client sends back. Lastly, you underestimate the problems associated with not holding the locks the cursor is using. As an example, it's likely that a btree indexscan wouldn't successfully restart at all, because it couldn't find where it had been if the index page had been split or deleted meanwhile. So not running VACUUM is not enough to guarantee the query will still work. regards, tom lane