Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VlMMy-0004ft-9C for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Nov 2013 17:24:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VlMMx-0000bE-OP for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Nov 2013 17:24:15 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VlMKy-0000RG-57 for pgsql-bugs@postgresql.org; Tue, 26 Nov 2013 17:22:12 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VlMKv-0006He-HD for pgsql-bugs@postgresql.org; Tue, 26 Nov 2013 17:22:11 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id rAQHM8S3009530; Tue, 26 Nov 2013 12:22:08 -0500 From: Tom Lane To: bricklen cc: "jonathan.camile" , pgsql-bugs@postgresql.org Subject: Re: BUG #8629: Strange resultset when using CTE or a subselect In-reply-to: References: <1385408337668-5780199.post@n5.nabble.com> <1385459415878-5780294.post@n5.nabble.com> Comments: In-reply-to bricklen message dated "Tue, 26 Nov 2013 08:52:04 -0800" Date: Tue, 26 Nov 2013 12:22:08 -0500 Message-ID: <9529.1385486528@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org bricklen writes: > On Tue, Nov 26, 2013 at 1:50 AM, jonathan.camile > wrote: >> I always have the same last result regardless of the offset or the limit I >> use. > I cannot reproduce your problem in 9.2.5 nor 9.3.1. Rerunning the query > with different OFFSET values gives me different results each time. I do reproduce the behavior, at least when offset+limit is small enough that the executor will use a top-N heapsort. As already stated, it's not a bug; the ordering is underdetermined so any set of the correct number of rows with status = 5 is a valid output. As for what's actually happening: the row that always shows up seems to be the physically first one with status = 5. I think that's starting out as the top of the top-N heap, and it just stays there because there's nothing that can displace it. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs