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 1pF7Jk-00075r-4p for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Jan 2023 05:37:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pF7Ji-0000vt-VC for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Jan 2023 05:36:58 +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 1pF7Ji-0000ux-Ls for pgsql-hackers@lists.postgresql.org; Tue, 10 Jan 2023 05:36:58 +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 1pF7Jg-0002Hs-Ip for pgsql-hackers@lists.postgresql.org; Tue, 10 Jan 2023 05:36:58 +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 30A5as6V212147; Tue, 10 Jan 2023 00:36:54 -0500 From: Tom Lane To: David Rowley cc: Ankit Kumar Pandey , pghackers , Vik Fearing Subject: Re: Todo: Teach planner to evaluate multiple windows in the optimal order In-reply-to: References: <83d80853-a45c-d85c-68eb-59acfe7fb5fb@gmail.com> <6ebcc137-45ea-6373-e3e1-3c304c452e1f@gmail.com> <441d135e-1941-c3ef-1649-18c3e8811549@postgresfriends.org> <9620d994-b89a-2dcf-fca5-821e19d56858@gmail.com> <01248493-182b-0f92-f2f2-ff28dc4b2e83@gmail.com> <2040c902-32b1-46c8-0b26-d3f43a16b9bb@gmail.com> <12f6ef19-e06e-8ea9-ad98-3fd92afb7f0b@gmail.com> <8d0b24ce-f8ba-cd63-82ae-be853b4067e8@gmail.com> <4ef7f947-526b! -c4ec-f7a0-8b4586e693e4@gmail.com> Comments: In-reply-to David Rowley message dated "Tue, 10 Jan 2023 18:23:50 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <212145.1673329014.1@sss.pgh.pa.us> Date: Tue, 10 Jan 2023 00:36:54 -0500 Message-ID: <212146.1673329014@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Ideally, our sort costing would just be better, but I think that > raises the bar a little too high to start thinking of making > improvements to that for this patch. It's trickier than it looks, cf f4c7c410e. But if you just want to add a small correction based on number of columns being sorted by, that seems within reach. See the comment for cost_sort though. Also, I suppose for incremental sorts we'd want to consider only the number of newly-sorted columns, but I'm not sure if that info is readily at hand either. regards, tom lane