X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DEFB2535A0 for ; Mon, 2 May 2005 08:17:35 -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 77556-08 for ; Mon, 2 May 2005 11:17:26 +0000 (GMT) Received: from fzkmail2.fzk.de (fzkmail2.fzk.de [141.52.27.52]) by svr1.postgresql.org (Postfix) with SMTP id 60871537EF for ; Mon, 2 May 2005 08:17:23 -0300 (ADT) Received: FROM resy5.fzk.de BY fzkmail2.fzk.de ; Mon May 02 13:17:18 2005 +0200 Received: from rodos.fzk.de (resy6.fzk.de [141.52.68.10]) by resy5.fzk.de (8.12.7/8.12.7/SuSE Linux 0.6) with ESMTP id j42BHCsG012399; Mon, 2 May 2005 13:17:14 +0200 Message-ID: <42760C37.BD6531A8@rodos.fzk.de> Date: Mon, 02 May 2005 13:17:11 +0200 From: Christoph Haller X-Mailer: Mozilla 4.77 [en] (X11; U; HP-UX B.10.20 9000/780) X-Accept-Language: en MIME-Version: 1.0 To: Andreas Kretschmer Cc: pgsql-sql@postgresql.org Subject: Re: how many tuples on a cursor? References: <20050502071358.GB5962@webserv.wug-glas.de> Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS - amavis-milter (http://www.amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/12 X-Sequence-Number: 21325 Andreas Kretschmer wrote: > > Hello, > > I want to know how many tuples there on a cursor, and i found > http://groups.google.de/groups?hl=de&lr=&threadm=3ACA7BB0.7020106%402cactus.com&rnum=7&prev=/groups%3Fhl%3Dde%26lr%3D%26q%3Dpostgres%2Bcursor%2Bcount%26btnG%3DSuche > > But, this posting is very old (2001-04-03), i'm using 7.4.6. > > Is there now a way to get the total number of rows in a CURSOR? > > Andreas > -- Assuming you are using the libpq interface, after FETCH ALL you'll get the number of rows by PQntuples(). What else seems to work is MOVE 2147483647 (INT_MAX) and then get the max number of rows by PQcmdTuples(). Back to the beginning by FETCH ABSOLUTE 0. But I have no idea how expensive this MOVE is. Regards, Christoph