Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGjNZ-00GqPk-9q for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Dec 2023 17:32:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rGjNX-009U0r-Vn for pgsql-hackers@arkaria.postgresql.org; Fri, 22 Dec 2023 17:32:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGjNX-009U0j-Mw for pgsql-hackers@lists.postgresql.org; Fri, 22 Dec 2023 17:32:07 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGjNV-00BhR0-Fn for pgsql-hackers@postgresql.org; Fri, 22 Dec 2023 17:32:06 +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 3BMHVqOH1067709; Fri, 22 Dec 2023 12:31:52 -0500 From: Tom Lane To: Heikki Linnakangas cc: Xiaoran Wang , pgsql-hackers , Andrew Kane , Matthias van de Meent Subject: Re: Avoid computing ORDER BY junk columns unnecessarily In-reply-to: <02c142a8-051d-4252-a3a5-9d87be1c6e6b@iki.fi> References: <2ca5865b-4693-40e5-8f78-f3b45d5378fb@iki.fi> <1052850.1703258655@sss.pgh.pa.us> <02c142a8-051d-4252-a3a5-9d87be1c6e6b@iki.fi> Comments: In-reply-to Heikki Linnakangas message dated "Fri, 22 Dec 2023 18:55:00 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1067707.1703266312.1@sss.pgh.pa.us> Date: Fri, 22 Dec 2023 12:31:52 -0500 Message-ID: <1067708.1703266312@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Heikki Linnakangas writes: > On 22/12/2023 17:24, Tom Lane wrote: >> How much of your patchset still makes sense if we assume that we >> can always extract the ORDER BY column values from the index? > That would make it much less interesting. But I don't think that's a > good assumption. Especially in the kNN case, the ORDER BY value would > not be stored in the index. Most likely the index needs to calculate it > in some form, but it might take shortcuts like avoiding the sqrt(). Yeah, fair point. I'll try to take a look at your patchset after the holidays. regards, tom lane