From oliveiros.cristina@marktest.pt Mon May 25 13:34:12 2009 Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 37DE763564B; Mon, 25 May 2009 10:34:12 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 70151-01-6; Mon, 25 May 2009 10:34:10 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id 401E5634986; Mon, 25 May 2009 10:32:18 -0300 (ADT) Received: from suite (suite.marktest.pt [10.61.90.236]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id K0H2PVF0; Mon, 25 May 2009 14:32:14 +0100 Message-ID: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> From: "Oliveiros Cristina" To: Cc: Subject: Obtaining a limited number of records from a long query Date: Mon, 25 May 2009 14:32:14 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_01FF_01C9DD45.98E00570" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200905/84 X-Sequence-Number: 21444 This is a multi-part message in MIME format. ------=_NextPart_000_01FF_01C9DD45.98E00570 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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 ------=_NextPart_000_01FF_01C9DD45.98E00570 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Dear List,
 
Is there any way to force a query to = return just a=20 few records?
 
For ex, returning just the first ten = rows from a=20 long ORDER BY query ?
 
And then, eventually, obtaining the = remaining=20 records at a later time, or in background?
 
Thanks in advance for your = help,
 
Best,
Oliveiros
------=_NextPart_000_01FF_01C9DD45.98E00570-- From lecneri@gmail.com Mon May 25 13:43:14 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id CA23F63509A; Mon, 25 May 2009 10:43:14 -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 33640-02-9; Mon, 25 May 2009 10:43:04 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-fx0-f174.google.com (mail-fx0-f174.google.com [209.85.220.174]) by mail.postgresql.org (Postfix) with ESMTP id 30B7F634C2A; Mon, 25 May 2009 10:42:28 -0300 (ADT) Received: by fxm22 with SMTP id 22so3332802fxm.19 for ; Mon, 25 May 2009 06:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=RXT8HsxWlu5AWeZDKywx8/D0F2xvrd1Kz9tRr3/lxA8=; b=Atkm443Tek7Ghz1/8aWMQFyEBAjBkChVFZYefIu0Bi/w7/gDCU8glLsJH3OZ+PhViP GA8CTfDmDy59tRHpnzh9M7wVOEohybO/VF6n45GLLc+0Bo52B+WWw0H+rFHQGhpyRGHD FAbyNGed1RtD0/ASgeiKKDG6KffF9uql/iunM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=MEvaQ+mptJ4XAK3/sew6Sh9Sgo/UhanlKJd2U6uewCkhZlZjeCNtkWgnvug+nqx2oU 5ZDKlliKCoHag40Xd+uNgtF35vrYMT6eGGy/cxHSLvPNKMhXduZcFIVxkOYY6lyIB65r oy73EI8sOagsFFwXc1u2jU6c64WiMZ2vE7p50= MIME-Version: 1.0 Received: by 10.239.130.196 with SMTP id 4mr446190hbk.17.1243258944462; Mon, 25 May 2009 06:42:24 -0700 (PDT) In-Reply-To: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> Date: Mon, 25 May 2009 10:42:24 -0300 Message-ID: <252e1f290905250642w66c6b962k248624b5327be043@mail.gmail.com> Subject: Re: Obtaining a limited number of records from a long query From: Luiz Eduardo Cantanhede Neri To: Oliveiros Cristina Cc: pgsql-sql@postgresql.org, pgsql-novice@postgresql.org Content-Type: multipart/alternative; boundary=001636499069bfa076046abcc78e X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=HTML_MESSAGE=0.001 X-Spam-Level: X-Archive-Number: 200905/85 X-Sequence-Number: 21445 --001636499069bfa076046abcc78e Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Visit http://www.sqlzoo.net/howto/source/z.dir/tip915069/postgres and u'll get ur awnser and others like from 11th and on. For now you may try SELECT * FROM cia LIMIT 10 On Mon, May 25, 2009 at 10:32 AM, Oliveiros Cristina < oliveiros.cristina@marktest.pt> 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 > --001636499069bfa076046abcc78e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Visit http://www.sqlzoo.net/howto/source/z.dir/tip915069/postgres and u= 9;ll get ur awnser and others like from 11th and on.

For now you may= try SELECT * FROM cia LIMIT 10

On Mon, May 25, 2009 at 10:32 AM, Oliveiros = Cristina <oliveiros.cristina@marktest.pt> wrote:
Dear List,
=A0
Is there any way to force a query to r= eturn just a=20 few records?
=A0
For ex, returning just the first ten r= ows from a=20 long ORDER BY query ?
=A0
And then, eventually, obtaining the re= maining=20 records at a later time, or in background?
=A0
Thanks in advance for your help,
=A0
Best,
Oliveiros

--001636499069bfa076046abcc78e-- From andy-lists@networkmail.eu Mon May 25 13:46:40 2009 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 From oliveiros.cristina@marktest.pt Mon May 25 13:58:14 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id E9E14634915 for ; Mon, 25 May 2009 10:58:14 -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 37957-04-4 for ; Mon, 25 May 2009 10:58:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id D633863583A for ; Mon, 25 May 2009 10:56:01 -0300 (ADT) Received: from suite (suite.marktest.pt [10.61.90.236]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id K0H2PV9F; Mon, 25 May 2009 14:55:55 +0100 Message-ID: <025501c9dd40$86155440$ec5a3d0a@marktestcr.marktest.pt> From: "Oliveiros Cristina" To: "Andy Shellam" Cc: References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> <4A1AA0FA.1070507@networkmail.eu> Subject: Re: Obtaining a limited number of records from a long query Date: Mon, 25 May 2009 14:55:54 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=0.001 X-Spam-Level: X-Archive-Number: 200905/106 X-Sequence-Number: 32598 Thanks a million, Andy. It's precisely what I needed, Indeed! Best, Oliveiros ----- Original Message ----- From: "Andy Shellam" To: "Oliveiros Cristina" Cc: Sent: Monday, May 25, 2009 2:45 PM Subject: Re: [SQL] Obtaining a limited number of records from a long query > 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 > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > From mail@webthatworks.it Mon May 25 14:14:00 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 060E9632D73 for ; Mon, 25 May 2009 11:14:00 -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 41884-05 for ; Mon, 25 May 2009 11:13:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtp-out25.alice.it (smtp-out25.alice.it [85.33.2.25]) by mail.postgresql.org (Postfix) with ESMTP id 6081F632323 for ; Mon, 25 May 2009 11:13:55 -0300 (ADT) Received: from FBCMMO02.fbc.local ([192.168.68.196]) by smtp-out25.alice.it with Microsoft SMTPSVC(6.0.3790.3959); Mon, 25 May 2009 16:13:52 +0200 Received: from FBCMCL01B01.fbc.local ([192.168.69.82]) by FBCMMO02.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Mon, 25 May 2009 16:13:52 +0200 Received: from kerberos.webthatworks.it ([82.50.69.203]) by FBCMCL01B01.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Mon, 25 May 2009 16:13:23 +0200 Received: from dawn.webthatworks.it (dawn.webthatworks.it [192.168.1.12]) by kerberos.webthatworks.it (Postfix) with ESMTP id DB4CCE6AE7 for ; Mon, 25 May 2009 16:13:49 +0200 (CEST) Received: from dawn.webthatworks.it (localhost [127.0.0.1]) by dawn.webthatworks.it (Postfix) with ESMTP id 823873DB19 for ; Mon, 25 May 2009 16:13:48 +0200 (CEST) Date: Mon, 25 May 2009 16:13:47 +0200 From: Ivan Sergio Borgonovo To: Subject: Re: Obtaining a limited number of records from a long query Message-ID: <20090525161347.166789ac@dawn.webthatworks.it> In-Reply-To: <025501c9dd40$86155440$ec5a3d0a@marktestcr.marktest.pt> References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> <4A1AA0FA.1070507@networkmail.eu> <025501c9dd40$86155440$ec5a3d0a@marktestcr.marktest.pt> Organization: http://www.webthatworks.it X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 May 2009 14:13:24.0287 (UTC) FILETIME=[F74564F0:01C9DD42] 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/107 X-Sequence-Number: 32599 On Mon, 25 May 2009 14:55:54 +0100 "Oliveiros Cristina" wrote: > > > Thanks a million, Andy. > > It's precisely what I needed, Indeed! Beware: unless you specify an ORDER BY (and you expect no other record is inserted between one query and the other... or you just don't care) you may incur in unexpected results. A query without an order by is not granted to return the result in the same order. If you can (same session) you may use cursors. -- Ivan Sergio Borgonovo http://www.webthatworks.it From DStaal@usa.net Mon May 25 14:15:53 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 9834A6335B4 for ; Mon, 25 May 2009 11:15:53 -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 42104-09 for ; Mon, 25 May 2009 11:15:43 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from powercell.magehandbook.com (173-8-4-45-WashingtonDC.hfc.comcastbusiness.net [173.8.4.45]) by mail.postgresql.org (Postfix) with ESMTP id 945E26334EE for ; Mon, 25 May 2009 11:15:52 -0300 (ADT) Received: from [192.168.1.50] (Mac-Pro.magehandbook.com [192.168.1.50]) by powercell.magehandbook.com (Postfix) with ESMTP id 4D13D285F2 for ; Mon, 25 May 2009 10:15:50 -0400 (EDT) Date: Mon, 25 May 2009 10:15:50 -0400 From: Daniel Staal Reply-To: PGSQL-Novice To: pgsql-novice@postgresql.org Subject: Re: Obtaining a limited number of records from a long query Message-ID: In-Reply-To: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> X-Mailer: Mulberry/4.0.8 (Mac OS X) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.1 tagged_above=0 required=5 tests=RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200905/86 X-Sequence-Number: 21446 --As of May 25, 2009 2:32:14 PM +0100, Oliveiros Cristina is alleged to have said: > 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, --As for the rest, it is mine. Depending on what you want, either LIMIT and OFFSET or a cursor will help you. Daniel T. Staal --------------------------------------------------------------- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --------------------------------------------------------------- From oliveiros.cristina@marktest.pt Mon May 25 14:21:03 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 5844F632323 for ; Mon, 25 May 2009 11:21:03 -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 43223-03 for ; Mon, 25 May 2009 11:20:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id 279D263462B for ; Mon, 25 May 2009 11:21:00 -0300 (ADT) Received: from suite (suite.marktest.pt [10.61.90.236]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id K0H2PYBP; Mon, 25 May 2009 15:20:57 +0100 Message-ID: <027f01c9dd44$054655e0$ec5a3d0a@marktestcr.marktest.pt> From: "Oliveiros Cristina" To: "Ivan Sergio Borgonovo" , References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt><4A1AA0FA.1070507@networkmail.eu><025501c9dd40$86155440$ec5a3d0a@marktestcr.marktest.pt> <20090525161347.166789ac@dawn.webthatworks.it> Subject: Re: Obtaining a limited number of records from a long query Date: Mon, 25 May 2009 15:20:57 +0100 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.001 tagged_above=0 required=5 tests=AWL=-0.000, STOX_REPLY_TYPE=0.001 X-Spam-Level: X-Archive-Number: 200905/108 X-Sequence-Number: 32600 Thank you for pointing it out, Ivan. The query I am trying to restrict output for happens to be an ORDER BY query. Actually I wasn't aware of this detail. I'll leave a mental note for myself that results might be unexpected for not ORDER BY queries Best, Oliveiros ----- Original Message ----- From: "Ivan Sergio Borgonovo" To: Sent: Monday, May 25, 2009 3:13 PM Subject: Re: [SQL] Obtaining a limited number of records from a long query > On Mon, 25 May 2009 14:55:54 +0100 > "Oliveiros Cristina" wrote: > >> >> >> Thanks a million, Andy. >> >> It's precisely what I needed, Indeed! > > Beware: unless you specify an ORDER BY (and you expect no other > record is inserted between one query and the other... or you just > don't care) you may incur in unexpected results. > > A query without an order by is not granted to return the result in > the same order. > > If you can (same session) you may use cursors. > > > -- > Ivan Sergio Borgonovo > http://www.webthatworks.it > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > From mail@webthatworks.it Mon May 25 15:04:02 2009 Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 294026336CE for ; Mon, 25 May 2009 12:04:02 -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 52832-03 for ; Mon, 25 May 2009 12:04:00 -0300 (ADT) Received: from mx3.hub.org (mx3.hub.org [206.223.169.73]) by mail.postgresql.org (Postfix) with ESMTP id 66CFC63367C for ; Mon, 25 May 2009 12:04:00 -0300 (ADT) X-Greylist: delayed 00:07:29.876386 by SQLgrey-1.7.6 Received: from smtp-out113.alice.it (smtp-out113.alice.it [85.37.17.113]) by mx3.hub.org (Postfix) with ESMTP id C30E037B687 for ; Mon, 25 May 2009 12:03:59 -0300 (ADT) Received: from FBCMMO03.fbc.local ([192.168.68.197]) by smtp-out113.alice.it with Microsoft SMTPSVC(6.0.3790.3959); Mon, 25 May 2009 16:56:24 +0200 Received: from FBCMCL01B04.fbc.local ([192.168.69.85]) by FBCMMO03.fbc.local with Microsoft SMTPSVC(6.0.3790.1830); Mon, 25 May 2009 16:56:24 +0200 Received: from kerberos.webthatworks.it ([82.50.69.203]) by FBCMCL01B04.fbc.local with Microsoft SMTPSVC(6.0.3790.3959); Mon, 25 May 2009 16:55:56 +0200 Received: from dawn.webthatworks.it (dawn.webthatworks.it [192.168.1.12]) by kerberos.webthatworks.it (Postfix) with ESMTP id C7C5BE6AE7 for ; Mon, 25 May 2009 16:56:17 +0200 (CEST) Received: from dawn.webthatworks.it (localhost [127.0.0.1]) by dawn.webthatworks.it (Postfix) with ESMTP id 79F5B3DB19 for ; Mon, 25 May 2009 16:56:17 +0200 (CEST) Date: Mon, 25 May 2009 16:56:17 +0200 From: Ivan Sergio Borgonovo To: pgsql-sql@postgresql.org Subject: Re: Obtaining a limited number of records from a long query Message-ID: <20090525165617.02d1658a@dawn.webthatworks.it> In-Reply-To: <027f01c9dd44$054655e0$ec5a3d0a@marktestcr.marktest.pt> References: <020201c9dd3d$372c3f40$ec5a3d0a@marktestcr.marktest.pt> <4A1AA0FA.1070507@networkmail.eu> <025501c9dd40$86155440$ec5a3d0a@marktestcr.marktest.pt> <20090525161347.166789ac@dawn.webthatworks.it> <027f01c9dd44$054655e0$ec5a3d0a@marktestcr.marktest.pt> Organization: http://www.webthatworks.it X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.1; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 25 May 2009 14:55:56.0807 (UTC) FILETIME=[E8B10970:01C9DD48] 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/109 X-Sequence-Number: 32601 On Mon, 25 May 2009 15:20:57 +0100 "Oliveiros Cristina" wrote: > Thank you for pointing it out, Ivan. > The query I am trying to restrict output for happens to be an > ORDER BY query. > Actually I wasn't aware of this detail. > I'll leave a mental note for myself that results might be > unexpected for not ORDER BY queries a bit more about "unexpected": - if people insert other rows... and by chance they happen to fall before the ones you already retrieved... no matter of the ORDER BY, you may "miss" them in the "paginated result". - without an order by there is no "granted" order. This is not a deficiency of PostgreSQL, it is not mandated by sql standard and it offers chances for optimisation The fact that without an order by clause they may return in the same order... is implementation dependent and Postgresql don't behave that way or it happens just by chance. -- Ivan Sergio Borgonovo http://www.webthatworks.it