How to get the total number of rows returned by query when using a cursor?

From: "Egor Shipovalov" <pgsql_list(at)eonline(dot)ru>
To: "Pgsql-General" <pgsql-general(at)postgresql(dot)org>
Subject: How to get the total number of rows returned by query when using a cursor?
Date: 2003-09-23 14:46:11
Message-ID: AKEFIKCGEAEFBICLBFBMOEJBCIAA.pgsql_list@eonline.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'm implementing paging through search results using cursors. Is there a
better way to know total number of rows under a cursor than running a
separate COUNT(*) query? I think PostgreSQL is bound to know this number
after the first FETCH, isn't it?

On a side note, why queries using LIMIT are SO terribly slow, compared to
cursors and sometimes even ones without LIMIT? Shouldn't LIMIT be internally
implemented using cursor mechanism then?

Best regards,
Egor Shipovalov.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Montervino, Mariano 2003-09-23 14:47:20 Especial delimiters caracter
Previous Message Bruce Momjian 2003-09-23 13:51:26 Re: after postgres upgrade - ERROR: current transaction