From: Andreas Joseph Krogh <andreak@officenet.no>
To: pgsql-sql@postgresql.org
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Subject: Re: Returning the total number of rows as a separate column when using limit
Date: Mon, 5 Nov 2007 15:38:34 +0100
Message-ID: <200711051538.34536.andreak@officenet.no> (raw)
In-Reply-To: <18728.1194272302@sss.pgh.pa.us>
References: <200711050836.38130.andreak@officenet.no>
<18728.1194272302@sss.pgh.pa.us>
On Monday 05 November 2007 15:18:22 Tom Lane wrote:
> Andreas Joseph Krogh <andreak@officenet.no> writes:
> > AFAICS the information about the *total* number of rows is in the
> > "result" somehow. When I execute a "limit 1" query with EXPLAIN ANALYZE,
> > I se the total number of columns in "rows=200819", so the information is
> > there.
>
> That's only an estimate. Since the query doesn't get executed to
> completion thanks to the LIMIT, Postgres really has no idea whether
> the estimate is accurate.
Ok. The query is ORDER-ed, but you're saying that it doesn't matter and PG
still doesn't have to know the total numbers even if it has to sort the
result?
Is there a way to perform the LIMIT-query only once and still be able to
extract the total number of rows from some "magic function", like
Oracle's "over()" analytic function? I will accept a simple "no" if that is
the case, but if it is possible (like it is in Oracle) I would appreciate to
know how to do it.
--
Andreas Joseph Krogh <andreak@officenet.no>
Senior Software Developer / Manager
------------------------+---------------------------------------------+
OfficeNet AS | The most difficult thing in the world is to |
Karenslyst Allé 11 | know how to do a thing and to watch |
PO. Box 529 Skøyen | somebody else doing it wrong, without |
0214 Oslo | comment. |
NORWAY | |
Tlf: +47 24 15 38 90 | |
Fax: +47 24 15 38 91 | |
Mobile: +47 909 56 963 | |
------------------------+---------------------------------------------+
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: andreak@officenet.no, tgl@sss.pgh.pa.us
Subject: Re: Returning the total number of rows as a separate column when using limit
In-Reply-To: <200711051538.34536.andreak@officenet.no>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox