Re: how many rows? [was Re: fetching rows]

Поиск
Список
Период
Сортировка
От Robert B. Easter
Тема Re: how many rows? [was Re: fetching rows]
Дата
Msg-id 0011171903570A.30061@comptechnews
обсуждение исходный текст
Ответ на how many rows? [was Re: fetching rows]  (Arnaud Vandyck <arnaud@ressource-toi.org>)
Список pgsql-sql
On Friday 17 November 2000 04:01, Arnaud Vandyck wrote:
> "Robert B. Easter" wrote:
> > > you can't do that with a cursor, but you can use they mysql-ism called
> > > a limit clause.  for example, to fetch rows 26-50 from that query,
> > > you'd do:
> > >
> > > select * from films limit 25,26;
> > >
> > > or
> > >
> > > select * from files limit 25 offset 26;
>
> I did know it was possible but did not know how to do, thanks (It was
> not my question but I'm glad to see the solution:)
>
> and how can I know how many rows are returned by the query?
>

I don't know exactly.  I don't know of any way to find the total number of 
rows in a cursor.  If you really need to know, you'll have to run a count(*) 
first, then make the cursor using the same select almost.  Once you get the 
count(*), you can then use MOVE and FETCH to get the page you want.

If someone has done it a better way, I'd like to hear how.  However, 
sometimes it is possible to cache a count(*) value somewhere in the database 
so it doesn't have to be found everytime - it depends on your database and 
what the select is if you can store the count in advance somehow.

> --
> Arnaud
> ( http://www.ressource-toi.org )

-- 
-------- Robert B. Easter  reaster@comptechnews.com ---------
- CompTechNews Message Board   http://www.comptechnews.com/ -
- CompTechServ Tech Services   http://www.comptechserv.com/ -
---------- http://www.comptechnews.com/~reaster/ ------------


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Why is this doing a seq scan?
Следующее
От: Roberto Mello
Дата:
Сообщение: Re: how many rows? [was Re: fetching rows]]