Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Chris <dmagick(at)gmail(dot)com>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, marcosborges(at)mbsi(dot)com(dot)br, pgsql-performance(at)postgresql(dot)org
Subject: Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can
Date: 2006-12-11 04:57:18
Message-ID: 26692.1165813038@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Chris <dmagick(at)gmail(dot)com> 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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Mark Kirkwood 2006-12-11 05:49:56 Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can
Previous Message Chris 2006-12-11 04:36:12 Re: SQL_CALC_FOUND_ROWS in POSTGRESQL / Some one can