pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Christoph Haller <ch@rodos.fzk.de>
To: Andreas Kretschmer <akretschmer@despammed.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: how many tuples on a cursor?
Date: Mon, 02 May 2005 13:17:11 +0200
Message-ID: <42760C37.BD6531A8@rodos.fzk.de> (raw)
References: <20050502071358.GB5962@webserv.wug-glas.de>

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&a...
> 
> 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



view thread (4+ messages)  latest in thread

Message-ID: <42760C37.BD6531A8@rodos.fzk.de>
Permalink:  ../42760C37.BD6531A8@rodos.fzk.de/
Also on:    postgresql.org/message-id/42760C37.BD6531A8@rodos.fzk.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: ch@rodos.fzk.de, akretschmer@despammed.com
  Subject: Re: how many tuples on a cursor?
  In-Reply-To: <42760C37.BD6531A8@rodos.fzk.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox