Re: use cursor in a function - Mailing list pgsql-novice

From Joe Conway
Subject Re: use cursor in a function
Date
Msg-id 3EEF5BCE.1000900@joeconway.com
Whole thread Raw
In response to Re: use cursor in a function  (Rory Campbell-Lange <rory@campbell-lange.net>)
Responses Re: use cursor in a function
List pgsql-novice
Rory Campbell-Lange wrote:
> In a nutshell:
>
> Is there a way of finding out how many rows (ROW_COUNT) are in a cursor
> select? If one can, is there a way of returning a RECORD containing the
> refcursor and the ROW_COUNT?
>

You aren't buying anything by using a cursor. AFAICS the only way that a
cursor would be a benefit, would be if it could persist from page to
page. Then you could grab just the needed tuples without requerying. But
I'm not aware of any way to do that.

So you might as well run a single
  "SELECT count(*) ... WHERE your_criteria_here"
to get the overall count once, and then run your LIMIT/OFFSET query
directly for each page.

Joe


pgsql-novice by date:

Previous
From: Rory Campbell-Lange
Date:
Subject: Re: use cursor in a function
Next
From: Lynna Landstreet
Date:
Subject: Re: Multibyte support and accented characters