Re: number of rows in a cursor - Mailing list pgsql-general

From scott.marlowe
Subject Re: number of rows in a cursor
Date
Msg-id Pine.LNX.4.33.0402100947110.28531-100000@css120.ihs.com
Whole thread Raw
In response to Re: number of rows in a cursor  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On Tue, 10 Feb 2004, Tom Lane wrote:

> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > Christoffer Gurell wrote:
> >> After declaring a cursor. Is there any way you can check the number of rows
> >> that cursor contains ??
>
> > Yes, you can MOVE ALL in the cursor and look at the return status,
>
> Note however that this is *not* a cheap operation.  You might as well
> fetch the data, because it's going to cost nearly as much as FETCH.
>
> (Worse, in pre-7.4 versions, MOVE BACKWARDS ALL is also nearly as
> expensive as FETCH, so that getting the number of rows and then fetching
> the data will cost you close to 3x the runtime of the FETCH alone.)

At that point wouldn't a select count(*) from table where...

be cheaper?


pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: fsync = true beneficial on ext3?
Next
From: "scott.marlowe"
Date:
Subject: Re: fsync = true beneficial on ext3?