From: | Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> |
---|---|
To: | newsreader(at)mediaone(dot)net |
Cc: | Tony Reina <reina(at)nsi(dot)edu>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Re: is this possible? it should be! |
Date: | 2001-08-21 05:30:07 |
Message-ID: | Pine.BSF.4.21.0108202227330.3144-100000@megazone23.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, 20 Aug 2001 newsreader(at)mediaone(dot)net wrote:
> On Mon, Aug 20, 2001 at 04:56:29PM -0700, Tony Reina wrote:
> > Perhaps GROUP BY will get you where you want to go:
> >
> > select count(*), a, b, c from a where d=2 group by a, b, c order by e limit 10;
> >
> >
>
> Here count(*) doesn't give total count i.e. grand total
> count if there is no "limit."
>
>
> What would be nice is if pg would return 10 rows but declare
> at the bottom of the display to give total rows number. This way
> DBI can just do
> $n=$sql->total_rows;
> or something like that. I think it requires a major
> hack on postgres? No? I don't think it will be
> any additional cpu cost to return total number of rows
> since sorting needs to know all rows and hence
> total number of rows
>
I don;'t know if it's considered now, but that query (the
original) doesn't necessarily require a sort step. With an index on
(d,e) I think you could do the query using the index for both the
constraint (d=2) and the ordering stopping when you have 10 rows.
From | Date | Subject | |
---|---|---|---|
Next Message | Stephan Szabo | 2001-08-21 05:32:39 | Re: Sort by foreign date column |
Previous Message | Andrey Y. Mosienko | 2001-08-21 04:48:57 | Sort by foreign date column |