Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id DB94D9FA249 for ; Mon, 11 Dec 2006 00:36:20 -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 57775-03 for ; Mon, 11 Dec 2006 00:36:15 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.236]) by postgresql.org (Postfix) with ESMTP id 97B369FA0EE for ; Mon, 11 Dec 2006 00:36:15 -0400 (AST) Received: by wx-out-0506.google.com with SMTP id i28so1592042wxd for ; Sun, 10 Dec 2006 20:36:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:user-agent:mime-version:to:cc:subject:references:in-reply-to:content-type:content-transfer-encoding; b=DBAUH86ie7jgEr2t9yksKG+lSFr7SoDVCcE0dJZR3rY8+eGMYoWggnEwuBJ1UpM0sS64plbqkYoM0R45Jl/pxegFKUR4AOa4TKZLMzdvE8mr/2I31HVreIIQGNZpbHLax5cQ9O+SNbaOr7Em1P/A4Ud2yz1ksDKefdtjYewwVnw= Received: by 10.70.40.1 with SMTP id n1mr4425700wxn.1165811774534; Sun, 10 Dec 2006 20:36:14 -0800 (PST) Received: from ?10.1.1.11? ( [203.217.18.65]) by mx.google.com with ESMTP id 6sm7660167wrh.2006.12.10.20.36.12; Sun, 10 Dec 2006 20:36:14 -0800 (PST) Message-ID: <457CE03C.1060707@gmail.com> Date: Mon, 11 Dec 2006 15:36:12 +1100 From: Chris User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: "Joshua D. Drake" CC: marcosborges@mbsi.com.br, pgsql-performance@postgresql.org Subject: Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can References: <457814D3.1030001@mbsi.com.br> <457CD182.7020004@gmail.com> <1165809878.19970.2.camel@localhost.localdomain> In-Reply-To: <1165809878.19970.2.camel@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/203 X-Sequence-Number: 22259 Joshua D. Drake wrote: > On Mon, 2006-12-11 at 14:33 +1100, Chris wrote: >> Marcos Borges wrote: >>> 07/12/2006 04:31 >>> *SQL_CALC_FOUND_ROWS in POSTGRESQL* >>> >>> In mysqln i m using the command SQL_CALC_FOUND_ROWS in follow sintax. >>> SELECT SQL_CALC_FOUND_ROWS name, email, tel FROM mytable WHERE name <> >>> '' LIMIT 0, 10 >>> to have the recorset data. >>> and >>> SELECT FOUND_ROWS(); >>> to have the total of registers found. >>> >>> I dont want to use the command count(*), because the performance will >>> fall down, depending of the quantyt of tables and "joins". >>> >>> The Data base postgresql have something similar ??? >> Nope, you're out of luck sorry. That's a mysql-ism and I doubt postgres >> will ever include something similar. > > Your language will have a similar binding. Something like pg_numrows. I guess they are similar but also not really :) The SQL_CALC_FOUND_ROWS directive in mysql will run the same query but without the limit. It's the same as doing a select count(*) type query using the same clauses, but all in one query instead of two. It doesn't return any extra rows on top of the limit query so it's better than using pg_numrows which runs the whole query and returns it to php (in this example). Their docs explain it: http://dev.mysql.com/doc/refman/4.1/en/information-functions.html See "FOUND_ROWS()" -- Postgresql & php tutorials http://www.designmagick.com/