pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andy Shellam <andy-lists@networkmail.eu>
To: Oliveiros Cristina <oliveiros.cristina@marktest.pt>
Cc: pgsql-sql@postgresql.org
Subject: Re: Obtaining a limited number of records from a long query
Date: Mon, 25 May 2009 14:45:30 +0100
Message-ID: <4A1AA0FA.1070507@networkmail.eu> (raw)
In-Reply-To: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt>
References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt>

Hi Oliveiros

Certainly!  What you're looking for is the LIMIT...OFFSET syntax.

Some examples:

SELECT ... LIMIT 10 - return the first 10 records only.
SELECT ... LIMIT 10 OFFSET 10 - return 10 records, starting with record 11.

Manual page:

http://www.postgresql.org/docs/8.3/interactive/queries-limit.html

Regards,
Andy

Oliveiros Cristina wrote:
> Dear List,
>  
> Is there any way to force a query to return just a few records?
>  
> For ex, returning just the first ten rows from a long ORDER BY query ?
>  
> And then, eventually, obtaining the remaining records at a later time, 
> or in background?
>  
> Thanks in advance for your help,
>  
> Best,
> Oliveiros



view thread (8+ messages)  latest in thread

Message-ID: <4A1AA0FA.1070507@networkmail.eu>
Permalink:  ../4A1AA0FA.1070507@networkmail.eu/
Also on:    postgresql.org/message-id/4A1AA0FA.1070507@networkmail.eu

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: andy-lists@networkmail.eu, oliveiros.cristina@marktest.pt
  Subject: Re: Obtaining a limited number of records from a long query
  In-Reply-To: <4A1AA0FA.1070507@networkmail.eu>

* 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