Re: Pagination - 1 or 2 queries?

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: Pagination - 1 or 2 queries?
Дата
Msg-id Pine.LNX.4.33.0309050837300.30535-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Pagination - 1 or 2 queries?  (CSN <cool_screen_name90001@yahoo.com>)
Ответы Re: Pagination - 1 or 2 queries?  (CSN <cool_screen_name90001@yahoo.com>)
Re: Pagination - 1 or 2 queries?  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-general
On Fri, 5 Sep 2003, CSN wrote:

> Since you usually need to know the total number of
> rows a query would return, do you think it's better
> to:
>
> a) Do one query with a LIMIT and OFFSET to get the
> results, and another COUNT query to get the total
> number of rows?
>
> b) Do a single query without a LIMIT and OFFSET, then
> do a seek or similiar to get at the rows you want?
>
> Most tutorials, code, etc. I've seen do "a". The
> eclipse library does "b".

Either way works.  Does the eclipse library use a cursor, or grab the
whole dataset and then seek on the client side?  If it uses a cursor, I'd
expect it to be the fastest and simplest implementation.  Since a lot of
libs are designed to work with MySQL, they often are written in the first
method, where select count(*) is quite quick on MySQL, and MySQL doesn't
have cursor support.

With Postgresql, the cursor is likely to be the faster method.


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: postmaster crashing
Следующее
От: Tom Lane
Дата:
Сообщение: Re: default EXECUTE privilege