count(*) and limit - Mailing list pgsql-sql

From Orion
Subject count(*) and limit
Date
Msg-id 9q4vc1$2nej$1@news.tht.net
Whole thread Raw
List pgsql-sql
I have a interface where users are paging through results of a query.  In 
order to do so I need to

select count(*) from data where stuff;

To find out how many pages of data there are ( needed for the navigation 
bar)

and then I need to 

select * from data where stuff limit X offset y;

Now, postgres has to get the whole result before running the limit.

Is there some trick to get how many rows there would be without the limit 
so I dont need to run the extra count(*) query?  It seems like a waste.
       Orion




pgsql-sql by date:

Previous
From: Stuart Grimshaw
Date:
Subject: Why would this slow the query down so much?
Next
From: leo
Date:
Subject: problem w/plpgsql proc