count(*) and limit

Поиск
Список
Период
Сортировка
От Orion
Тема count(*) and limit
Дата
Msg-id 9q4vc1$2nej$1@news.tht.net
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Stuart Grimshaw
Дата:
Сообщение: Why would this slow the query down so much?
Следующее
От: leo
Дата:
Сообщение: problem w/plpgsql proc