Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Magnus Hagander
> > Nope, the query is way too expensive to run it twice. (GIN > scan over > > well over half a million rows. It's faster to do the > > get-as-cursor-then-loop-and-increment, I've measured that) > > Can't you select into a temporary table and then do select > count(*) over that table, aswell a

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread redhog
> Nope, the query is way too expensive to run it twice. (GIN scan over > well over half a million rows. It's faster to do the > get-as-cursor-then-loop-and-increment, I've measured that) Can't you select into a temporary table and then do select count(*) over that table, aswell as run your cursor

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Magnus Hagander
> > > I can deal with materializing the resultset, but I want > to get away > > > from the loop-a-thousand-times-doing-plus-one... > > > > i dont think its possible. note that you can make a > refcursor inside > > your plpgsql function and pass it to an sql function which > can do sql > > cu

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Merlin Moncure
On 11/3/06, Richard Troy <[EMAIL PROTECTED]> wrote: On Fri, 3 Nov 2006, Merlin Moncure wrote: > > > > I can deal with materializing the resultset, but I want to get away from > > the loop-a-thousand-times-doing-plus-one... > > i dont think its possible. note that you can make a refcursor inside

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Richard Troy
On Fri, 3 Nov 2006, Merlin Moncure wrote: > > > > I can deal with materializing the resultset, but I want to get away from > > the loop-a-thousand-times-doing-plus-one... > > i dont think its possible. note that you can make a refcursor inside > your plpgsql function and pass it to an sql function

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Merlin Moncure
On 11/3/06, Magnus Hagander <[EMAIL PROTECTED]> wrote: > > Is there any way to count how many hits I got in a cursor > in PL/pgsql? > > > > I have a function that will "window" through the result of > a (large) > > query based on two parameters, but I also want to return > the number of > > hits

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Magnus Hagander
> > Is there any way to count how many hits I got in a cursor > in PL/pgsql? > > > > I have a function that will "window" through the result of > a (large) > > query based on two parameters, but I also want to return > the number of > > hits to the client. Right now I'm looping through the e

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Martijn van Oosterhout
On Thu, Nov 02, 2006 at 10:43:58PM +0100, Magnus Hagander wrote: > Is there any way to count how many hits I got in a cursor in PL/pgsql? > > I have a function that will "window" through the result of a (large) > query based on two parameters, but I also want to return the number of > hits to the

Re: [GENERAL] Counting records in a PL/pgsql cursor

2006-11-03 Thread Richard Huxton
Magnus Hagander wrote: Is there any way to count how many hits I got in a cursor in PL/pgsql? I have a function that will "window" through the result of a (large) query based on two parameters, but I also want to return the number of hits to the client. Right now I'm looping through the entire

[GENERAL] Counting records in a PL/pgsql cursor

2006-11-02 Thread Magnus Hagander
Is there any way to count how many hits I got in a cursor in PL/pgsql? I have a function that will "window" through the result of a (large) query based on two parameters, but I also want to return the number of hits to the client. Right now I'm looping through the entire cursor and incrementing a