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 606D252A15 for ; Thu, 7 Jul 2005 04:42:00 -0300 (ADT) 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 34922-06 for ; Thu, 7 Jul 2005 07:41:54 +0000 (GMT) Received: from dns.texnet.it (dns.texnet.it [217.19.150.6]) by svr1.postgresql.org (Postfix) with ESMTP id B686852A0A for ; Thu, 7 Jul 2005 04:41:52 -0300 (ADT) Received: from pool-a-150.texnet.it ([217.19.150.150] helo=paros.rigacci.org) by dns.texnet.it with esmtp (Exim 3.35 #1 (Debian)) id 1DqR13-0000qJ-00; Thu, 07 Jul 2005 09:41:49 +0200 Received: from niccolo by paros.rigacci.org with local (Exim 4.50) id 1DqR11-0004HG-V5; Thu, 07 Jul 2005 09:41:47 +0200 Date: Thu, 7 Jul 2005 09:41:47 +0200 To: John A Meinel Cc: Postgresql Performance Subject: Re: CURSOR slowes down a WHERE clause 100 times? Message-ID: <20050707074147.GA16360@rigacci.org> References: <20050706211946.GA3460@rigacci.org> <42CC4D1C.9040606@arbash-meinel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42CC4D1C.9040606@arbash-meinel.com> User-Agent: Mutt/1.5.9i From: Niccolo Rigacci X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.153 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200507/58 X-Sequence-Number: 13299 > >Can the CURSOR on JOIN affects so heavly the WHERE clause? I > >suspect that - with the CURSOR - a sequential scan is performed > >on the entire data set for each fetched record... > > > >Any idea? > > > > > What does it say if you do "EXPLAIN ANALYZE SELECT..." both with and > without the cursor? > It may not say much for the cursor, but I think you can explain analyze > the fetch statements. How can I EXPLAIN ANALYZE a cursor like this? BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT ... FETCH ALL IN mycursor; END; I tried to put EXPLAIN ANALYZE in front of the SELECT and in front of the FETCH, but I got two "syntax error"... Thanks -- Niccolo Rigacci Firenze - Italy War against Iraq? Not in my name!