X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 98E67D72C6 for ; Wed, 24 Aug 2005 14:46:23 -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 70368-05 for ; Wed, 24 Aug 2005 17:46:22 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id A06F0D7285 for ; Wed, 24 Aug 2005 14:46:21 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.3/8.13.3) with ESMTP id j7OHkDgF016508 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 24 Aug 2005 11:46:16 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.3/8.13.3) with ESMTP id j7OHkDe6080758; Wed, 24 Aug 2005 11:46:13 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.3/8.13.3/Submit) id j7OHkDJL080757; Wed, 24 Aug 2005 11:46:13 -0600 (MDT) (envelope-from mfuhr) Date: Wed, 24 Aug 2005 11:46:12 -0600 From: Michael Fuhr To: Bo Lorentsen Cc: Russell Simpkins , pgsql-sql@postgresql.org Subject: Re: Number of rows in a cursor ? Message-ID: <20050824174612.GB80642@winnie.fuhr.org> References: <430C4C70.2010005@netgroup.dk> <430C6CFF.9070304@netgroup.dk> <20050824131921.GA39444@winnie.fuhr.org> <430C842C.8000504@netgroup.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <430C842C.8000504@netgroup.dk> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 required=5 tests=[AWL=0.005] X-Spam-Level: X-Archive-Number: 200508/230 X-Sequence-Number: 22458 On Wed, Aug 24, 2005 at 04:29:00PM +0200, Bo Lorentsen wrote: > Michael Fuhr wrote: > >...which is the same reason a cursor doesn't know how many rows it will > >fetch until you fetch them all (or MOVE to the end of the cursor, > >which fetches the rows internally). > > So, Postgresql is not hidding something for me, it just, like me, don't > know ? Right -- when you open a cursor PostgreSQL doesn't know how many rows it will return. PostgreSQL selects a query plan based on an *estimate* of how many rows the query will return, but until you fetch all the rows you can't know for sure how many rows there will be. -- Michael Fuhr