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 C529A32B1AB for ; Tue, 12 Oct 2004 15:08:05 +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 26915-02 for ; Tue, 12 Oct 2004 14:07:53 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 964C132B19A for ; Tue, 12 Oct 2004 15:07:56 +0100 (BST) 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 i9CE7vuv001857; Tue, 12 Oct 2004 10:07:57 -0400 (EDT) To: my ho Cc: pgsql-performance@postgresql.org Subject: Re: execute cursor fetch In-reply-to: <20041012114343.69531.qmail@web54110.mail.yahoo.com> References: <20041012114343.69531.qmail@web54110.mail.yahoo.com> Comments: In-reply-to my ho message dated "Tue, 12 Oct 2004 04:43:43 -0700" Date: Tue, 12 Oct 2004 10:07:56 -0400 Message-ID: <1856.1097590076@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/163 X-Sequence-Number: 8639 my ho writes: > If anyone can help pls, I have a question abt the > execution of cursor create/fetch/move , in particular > about disk cost. When a cursor is created, is the > whole table (with the required columns) got put into > memory? No. The plan is set up and then incrementally executed each time you say FETCH. > how does postgre speed up the query in > compare to normal selection? The only difference from a SELECT is that the planner will prefer "fast-start" plans, on the theory that you may not be intending to retrieve the whole result. For instance it might prefer an indexscan to a seqscan + sort, when it otherwise wouldn't. regards, tom lane