Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 666729FA0EE for ; Mon, 11 Dec 2006 00:57:25 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 59111-07 for ; Mon, 11 Dec 2006 00:57:20 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 095E69F9392 for ; Mon, 11 Dec 2006 00:57:20 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kBB4vI5O026693; Sun, 10 Dec 2006 23:57:18 -0500 (EST) To: Chris cc: "Joshua D. Drake" , marcosborges@mbsi.com.br, pgsql-performance@postgresql.org Subject: Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can In-reply-to: <457CE03C.1060707@gmail.com> References: <457814D3.1030001@mbsi.com.br> <457CD182.7020004@gmail.com> <1165809878.19970.2.camel@localhost.localdomain> <457CE03C.1060707@gmail.com> Comments: In-reply-to Chris message dated "Mon, 11 Dec 2006 15:36:12 +1100" Date: Sun, 10 Dec 2006 23:57:18 -0500 Message-ID: <26692.1165813038@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/204 X-Sequence-Number: 22260 Chris writes: > Their docs explain it: > http://dev.mysql.com/doc/refman/4.1/en/information-functions.html > See "FOUND_ROWS()" Sounds like a pretty ugly crock ... The functionality as described is to let you fetch only the first N rows, and then still find out the total number of rows that could have been returned. You can do that in Postgres with a cursor: DECLARE c CURSOR FOR SELECT ... (no LIMIT here); FETCH n FROM c; MOVE FORWARD ALL IN c; -- then figure the sum of the number of rows fetched and the -- rows-moved count reported by MOVE regards, tom lane