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 1ryjNS-000A5Q-Vh for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Apr 2024 02:25:54 +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 1ryjNQ-00Gzbv-Nu for pgsql-bugs@arkaria.postgresql.org; Mon, 22 Apr 2024 02:25:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryjNQ-00Gzbm-Fd for pgsql-bugs@lists.postgresql.org; Mon, 22 Apr 2024 02:25:52 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ryjNJ-002GJT-Oz for pgsql-bugs@lists.postgresql.org; Mon, 22 Apr 2024 02:25:51 +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 43M2Pg3j2909006; Sun, 21 Apr 2024 22:25:42 -0400 From: Tom Lane To: David Rowley cc: hu_yajun@qq.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18442: Unnecessary Sort operator in indexScan Plan In-reply-to: References: <18442-aca4c9134416990e@postgresql.org> <2135177.1713535423@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Mon, 22 Apr 2024 13:53:02 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2909004.1713752742.1@sss.pgh.pa.us> Date: Sun, 21 Apr 2024 22:25:42 -0400 Message-ID: <2909005.1713752742@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Couldn't strict equality conditions be handled using the same method > that we use to handle an Eclass with two distinct Consts. e.g a = 1 > and a=b and b=2? Perhaps, but it'd be a bit odd and confusing to treat two NULLs as distinct rather than equal. On the whole I'm disinclined to add complexity around this. My gut says there are more semantic gotchas than this one, and I think the use-case is at best pretty hokey. If your data design requires using NULL as though it's a normal data value, you're in a state of sin already, and you're going to find SQL fighting you all the way. (A question closely related to this is whether IS NOT DISTINCT FROM could be optimized more like regular equality. I'm not convinced about the use-case there either, although perhaps it's worth looking into.) regards, tom lane