Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBfeI-0003Hd-06 for pgsql-bugs@arkaria.postgresql.org; Mon, 15 Feb 2021 15:18:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lBfeG-00037A-R4 for pgsql-bugs@arkaria.postgresql.org; Mon, 15 Feb 2021 15:18:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBfeG-000373-Kr for pgsql-bugs@lists.postgresql.org; Mon, 15 Feb 2021 15:18:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lBfeE-0006qo-Kh for pgsql-bugs@lists.postgresql.org; Mon, 15 Feb 2021 15:18:52 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 11FFIk3R2251078; Mon, 15 Feb 2021 10:18:46 -0500 From: Tom Lane To: James Coleman cc: Neil Chen , contact@yorhel.nl, PostgreSQL mailing lists Subject: Re: BUG #16846: "retrieved too many tuples in a bounded sort" In-reply-to: References: <16846-ae49f51ac379a4cb@postgresql.org> <6068.1612484232@sss.pgh.pa.us> <1451384.1613063158@sss.pgh.pa.us> Comments: In-reply-to James Coleman message dated "Mon, 15 Feb 2021 08:55:40 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2251076.1613402326.1@sss.pgh.pa.us> Date: Mon, 15 Feb 2021 10:18:46 -0500 Message-ID: <2251077.1613402326@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk James Coleman writes: > On Thu, Feb 11, 2021 at 12:06 PM Tom Lane wrote: >> I stared at this for awhile and eventually convinced myself that it >> implemented the same logic, but it still seems overly complex. We >> do not need either the firstTuple or lastTuple flags, and we could >> convert the nTuple adjustments into a normal for-loop with (IMO) >> much greater intelligibility. What do you think of the attached? > Yes, that looks even better. Not sure how I missed that I'd just > reimplemented a normal for-loop with firstTuple/lastTuple conditions, > but I guess that's the benefit of coming at it with fresh eyes and > without the history of how it got the way it was. > +1 on committing v2. Sounds good, pushed. regards, tom lane