I know the bad way...what is the good way? - Mailing list pgsql-general

From Rick Schumeyer
Subject I know the bad way...what is the good way?
Date
Msg-id 454B4CC8.4070705@ieee.org
Whole thread Raw
Responses Re: I know the bad way...what is the good way?  (Richard Huxton <dev@archonet.com>)
Re: I know the bad way...what is the good way?  (Jeff Davis <pgsql@j-davis.com>)
List pgsql-general
I confess to having once written code that prints something like
"Items # 1 to 10 of 45"
by using select count(*) from t where condition; and select * from t
where condition limit 10 offset x;

I now know this is "bad", I guess because of the count() and the offset.

So what is the preferred way?  If it matters, my new application is
servlet based, so I believe (but not positive) this means cursors are an
option?  Is this a better way to do this?

pgsql-general by date:

Previous
From: Richard Troy
Date:
Subject: Re: Counting records in a PL/pgsql cursor
Next
From: "Merlin Moncure"
Date:
Subject: Re: Counting records in a PL/pgsql cursor