Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id A28D86342E7 for ; Mon, 25 May 2009 10:46:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 34702-01 for ; Mon, 25 May 2009 10:46:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-gw30.mailanyone.net (smtp-gw30.mailanyone.net [208.70.128.56]) by mail.postgresql.org (Postfix) with ESMTP id D873B632323 for ; Mon, 25 May 2009 10:46:35 -0300 (ADT) Received: from mailanyone.net by smtp-gw30.mailanyone.net with esmtpa (MailAnyone extSMTP andy@networkmail.eu) id 1M8aTb-0003wP-3s; Mon, 25 May 2009 08:44:27 -0500 Message-ID: <4A1AA0FA.1070507@networkmail.eu> Date: Mon, 25 May 2009 14:45:30 +0100 From: Andy Shellam User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Oliveiros Cristina CC: pgsql-sql@postgresql.org Subject: Re: Obtaining a limited number of records from a long query References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> In-Reply-To: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/105 X-Sequence-Number: 32597 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