| From: | Christoph Haller <ch(at)rodos(dot)fzk(dot)de> |
|---|---|
| To: | Andreas Kretschmer <akretschmer(at)despammed(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: how many tuples on a cursor? |
| Date: | 2005-05-02 11:17:11 |
| Message-ID: | 42760C37.BD6531A8@rodos.fzk.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2005-05-02 15:04:09 | Re: how many tuples on a cursor? |
| Previous Message | Mauro Bertoli | 2005-05-02 09:10:14 | Re: PHP postgres connections |