Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 1E7A19F959C for ; Mon, 5 Nov 2007 10:18:37 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 24454-08 for ; Mon, 5 Nov 2007 10:18:25 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 539DF9F958B for ; Mon, 5 Nov 2007 10:18:33 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id lA5EIMLv018729; Mon, 5 Nov 2007 09:18:22 -0500 (EST) To: Andreas Joseph Krogh cc: pgsql-sql Subject: Re: Returning the total number of rows as a separate column when using limit In-reply-to: <200711050836.38130.andreak@officenet.no> References: <200711050836.38130.andreak@officenet.no> Comments: In-reply-to Andreas Joseph Krogh message dated "Mon, 05 Nov 2007 08:36:38 +0100" Date: Mon, 05 Nov 2007 09:18:22 -0500 Message-ID: <18728.1194272302@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200711/12 X-Sequence-Number: 29540 Andreas Joseph Krogh 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. regards, tom lane