pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Robert B. Easter <reaster@comptechnews.com>
To: Arnaud Vandyck <arnaud@ressource-toi.org>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: how many rows? [was Re: fetching rows]
Date: Fri, 17 Nov 2000 19:03:57 -0500
Message-ID: <0011171903570A.30061@comptechnews> (raw)
In-Reply-To: <3A14F3E8.1FD2685F@ressource-toi.org>
References: <NDBBJGGFCLFEEGHHKCABCEGCDIAA.nmmm@nmmm.nu>
	<00111622091407.30061@comptechnews>
	<3A14F3E8.1FD2685F@ressource-toi.org>

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/ ------------



view thread (4+ messages)  latest in thread

Message-ID: <0011171903570A.30061@comptechnews>
Permalink:  ../0011171903570A.30061@comptechnews/
Also on:    postgresql.org/message-id/0011171903570A.30061@comptechnews

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: reaster@comptechnews.com, arnaud@ressource-toi.org
  Subject: Re: how many rows? [was Re: fetching rows]
  In-Reply-To: <0011171903570A.30061@comptechnews>
  References: <NDBBJGGFCLFEEGHHKCABCEGCDIAA.nmmm@nmmm.nu> <00111622091407.30061@comptechnews> <3A14F3E8.1FD2685F@ressource-toi.org> <0011171903570A.30061@comptechnews>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox