From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Rainer Bauer <usenet(at)munnin(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Yet Another COUNT(*)...WHERE...question |
Date: | 2007-08-16 12:02:58 |
Message-ID: | 20070816120258.GA15940@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, Aug 16, 2007 at 01:09:32PM +0200, Rainer Bauer wrote:
> Anyway, what Phoenix is trying to say is that 2 queries are required: One to
> get the total count and one to get the tuples for the current page. I reckon
> it would help, if the query returning the result set could also report the
> total no. of tuples found. Somthing like
> SELECT COUNT(*), * FROM <table> WHERE <cond> OFFSET <o> LIMIT <l>
Well, thee is another possibility, use cursors:
DECLARE CURSOR ... AS <query>;
FETCH 30 -- or however many to want now
MOVE TO END -- or whatever the command is, this gives you the number of rows
Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2007-08-16 12:37:15 | Re: INSERT before UPDATE? |
Previous Message | Phoenix Kiula | 2007-08-16 11:57:10 | Re: Fastest way to import only ONE column into a table? (COPY doesn't work) |