| From: | "Magnus Hagander" <mha(at)sollentuna(dot)net> |
|---|---|
| To: | "redhog" <redhog(at)redhog(dot)org>, <pgsql-general(at)postgresql(dot)org> |
| Subject: | Re: Counting records in a PL/pgsql cursor |
| Date: | 2006-11-03 14:43:06 |
| Message-ID: | 6BCB9D8A16AC4241919521715F4D8BCEA358A1@algol.sollentuna.se |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
> > 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 over that
> temporary table?
> Or is that way to space expensive?
I could, but just looping through the resultset is cheaper than that -
everything sticks in memory. The actual resultset isn't thatbig (max
1,000 rows), so there is no real risk to run out of memory for it inside
the functino.
//Magnus
| From | Date | Subject | |
|---|---|---|---|
| Next Message | A. Kretschmer | 2006-11-03 14:44:05 | Re: problem accessing a database |
| Previous Message | redhog | 2006-11-03 14:39:29 | Re: Counting records in a PL/pgsql cursor |