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 1uhhlr-002zp7-8q for pgsql-bugs@arkaria.postgresql.org; Fri, 01 Aug 2025 04:53:31 +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 1uhhlq-005MIr-6c for pgsql-bugs@arkaria.postgresql.org; Fri, 01 Aug 2025 04:53:30 +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 1uhhlp-005MIj-Uw for pgsql-bugs@lists.postgresql.org; Fri, 01 Aug 2025 04:53:29 +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.96) (envelope-from ) id 1uhhln-0008o7-1Y for pgsql-bugs@lists.postgresql.org; Fri, 01 Aug 2025 04:53:29 +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 5714rNfe2197760; Fri, 1 Aug 2025 00:53:23 -0400 From: Tom Lane To: Tender Wang cc: Richard Guo , Peter Eisentraut , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19000: gist index returns inconsistent result with gist_inet_ops In-reply-to: References: <19000-2525470d200672ab@postgresql.org> <2107725.1753985855@sss.pgh.pa.us> <2189027.1754019208@sss.pgh.pa.us> Comments: In-reply-to Tender Wang message dated "Fri, 01 Aug 2025 12:38:00 +0800" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <2197758.1754024003.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Fri, 01 Aug 2025 00:53:23 -0400 Message-ID: <2197759.1754024003@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tender Wang writes: > Tom Lane 于2025年8月1日周五 11:33写道: >> Richard Guo writes: >>> On Fri, Aug 1, 2025 at 3:17 AM Tom Lane wrote: >>>> We've known about this for, um, decades: btree_gist's support for >>>> inet/cidr is fundamentally broken [1][2]. > What I debugged yesterday was, in gbt_inet_consistent(), > query = convert_network_to_scalar(dquery, INETOID, &failure); Right --- as I mentioned in one of the linked threads, the thing that is fundamentally wrong here is relying on convert_network_to_scalar in the first place. That has no charter to deliver exact results, and it doesn't. In the present example I think the issue is that it doesn't consider the netmask at all; but there are many other cases where it's not an exact representation of inet's sort order. That's not a big problem for its intended purpose for statistical estimates, but it's completely fatal for index infrastructure. regards, tom lane