Thread: count(*) and limit

count(*) and limit

From
Orion
Date:
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