pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris <dmagick@gmail.com>
To: Joshua D. Drake <jd@commandprompt.com>
Cc: marcosborges@mbsi.com.br
Cc: pgsql-performance@postgresql.org
Subject: Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can
Date: Mon, 11 Dec 2006 15:36:12 +1100
Message-ID: <457CE03C.1060707@gmail.com> (raw)
In-Reply-To: <1165809878.19970.2.camel@localhost.localdomain>
References: <457814D3.1030001@mbsi.com.br>
	<457CD182.7020004@gmail.com>
	<1165809878.19970.2.camel@localhost.localdomain>

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/



view thread (9+ messages)  latest in thread

Message-ID: <457CE03C.1060707@gmail.com>
Permalink:  ../457CE03C.1060707@gmail.com/
Also on:    postgresql.org/message-id/457CE03C.1060707@gmail.com

 · 

reply

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-performance@postgresql.org
  Cc: dmagick@gmail.com, jd@commandprompt.com, marcosborges@mbsi.com.br
  Subject: Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can
  In-Reply-To: <457CE03C.1060707@gmail.com>

* 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