On Monday 05 November 2007 15:18:22 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 | | ------------------------+---------------------------------------------+ ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend