Re: Can This be done

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Can This be done
Дата
Msg-id 20020514112906.A8900@svana.org
обсуждение исходный текст
Ответ на Re: Can This be done  (Uros Gruber <uros@sir-mag.com>)
Список pgsql-general
On Mon, May 13, 2002 at 08:23:29PM +0200, Uros Gruber wrote:
> Hi,
>
> I know that select return a number of records, but i i use
> LIMIT i can't know how many row actualy is, because it's
> alway smaller than limit.
>
> Only solution I know for now is with 2 queryes. First query
> to get all the data, and than second with limit. But this is
> not something i want.

I'm afraid you're stuck here. To work out how many rows there are, the
system has to evaluate the entire query. And if you're evaluating the entire
query, you may as well use the entire result set.

It may be helpful to decide whether you really need the number of rows. For
example, Google only provides an estimate unless it really is a small number
of matches. If all you want it know whether to provide a next link, do limit
(number of rows+1). If the extra now is there, provide a next link.

HTH,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Canada, Mexico, and Australia form the Axis of Nations That
> Are Actually Quite Nice But Secretly Have Nasty Thoughts About America

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

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Quotes in SQL
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Configure problems with readline Mandrake 8.2 and postgres 7.2.1