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 1ulPVB-0009p2-Ut for pgsql-novice@arkaria.postgresql.org; Mon, 11 Aug 2025 10:11:38 +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 1ulPV9-00Bbms-Gd for pgsql-novice@arkaria.postgresql.org; Mon, 11 Aug 2025 10:11:35 +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 1ulPV8-00BbmE-MK for pgsql-novice@lists.postgresql.org; Mon, 11 Aug 2025 10:11:35 +0000 Received: from fhigh-b7-smtp.messagingengine.com ([202.12.124.158]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1ulPV3-0000VB-2R for pgsql-novice@postgresql.org; Mon, 11 Aug 2025 10:11:33 +0000 Received: from phl-compute-09.internal (phl-compute-09.internal [10.202.2.49]) by mailfhigh.stl.internal (Postfix) with ESMTP id 4B20F7A007E; Mon, 11 Aug 2025 06:11:27 -0400 (EDT) Received: from phl-imap-16 ([10.202.2.88]) by phl-compute-09.internal (MEProxy); Mon, 11 Aug 2025 06:11:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=de.me.tz; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1754907087; x=1754993487; bh=wNGC5U9WVTvhPYHt3jZOvWgCyEU11siwYZgh/WFcJnI=; b= oZNhQAiClRR4GVQALh63Nyrj95mYvisLIYkB7iSGR24AykyI8hfe5lG6qbPmFPZc NbHQCma5YSWnAGrdYWLfdD83i2SlBMRG8cdvivi8wJZE0nNNZYvcMcO0VIFPmE+c 9xFqZRtnzMvemn3QeZjsnacGZt17Sj45TQevi06mQUOyVAi4Ycx5r5mkSt1b3n2h OtBZC2el0djWCrX6ictR0uraN4m5TWCFbi5Xxplwt0KdaASihYOSWdN3Fp47tQ+B 0o/AeKtSt6Ph2tGsrAkR+BTH0auRy1joPa7WLysxA6/JUGjPE6BGfd3Srbk3qXIB M1NgYqAI0PksGILnB6CJfg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1754907087; x= 1754993487; bh=wNGC5U9WVTvhPYHt3jZOvWgCyEU11siwYZgh/WFcJnI=; b=P cgufHpJpD+mM1afq28dOHWGhIXwEd5uEppZw7lWS/E3SG7yb+DrZ5GVDG/AInrwQ MIqHclbiNrW0gDRVHsmrgSgHIkWdyKwBdy+JB1MMKg6fZiBbx3GQ+GqzHbkpbttF nZoTrMthIDg9ZEfh7YqvyzN86rQ4bv/bsfqLFyGYIwmg+T+bfh+YL4mxJSplDqYz bBIHr2TsrkDLoEeu3qFPqG6/YCfZPx0DGy0uKZWgDWreyos9L4eg7z+qwnzeXIAl bp7NlaeFg6lsTCNoMSLGfnSAO8vopeaNswhE25sAlUu1wCGxTOte8gtVo0mZFzTs +f6livUpwQFrJtZF7p6Zw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddufedvudekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefoggffhffvvefkjghfufgtgfesthejre dtredttdenucfhrhhomhepfdfsuhgvnhhtihhnucguvgcuofgvthiifdcuoehquhgvnhht ihhnseguvgdrmhgvrdhtiieqnecuggftrfgrthhtvghrnhephffhffdtveevgfegteetgf ffleevudffuedufeelvefhtefgkeekvefhvdffgffgnecuffhomhgrihhnpehpohhsthhg rhgvshhqlhdrohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrih hlfhhrohhmpehquhgvnhhtihhnseguvgdrmhgvrdhtiidpnhgspghrtghpthhtohepvddp mhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlhdqnhhovhhitggvsehpoh hsthhgrhgvshhqlhdrohhrghdprhgtphhtthhopehtghhlsehsshhsrdhpghhhrdhprgdr uhhs X-ME-Proxy: Feedback-ID: i7a6842ed:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 5669E2CC0083; Mon, 11 Aug 2025 06:11:26 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: T62e4ca0b1028eae6 Date: Mon, 11 Aug 2025 12:11:05 +0200 From: "Quentin de Metz" To: "Tom Lane" Cc: pgsql-novice@postgresql.org Message-Id: <7680b9a0-5e90-402e-ba56-e3ffca80c44c@app.fastmail.com> In-Reply-To: <4037726.1738356169@sss.pgh.pa.us> References: <58782480-ab75-4416-a177-ccf91be288a9@app.fastmail.com> <4037726.1738356169@sss.pgh.pa.us> Subject: Re: btree_gin, bigint and number literals Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hello Tom, I see that you have commited a change (e2b64fcef35f70f96fa92db56fbfa9ac2da136c7) which addresses this issue. Thank you! I looked into this issue recently and still don't understand why this would not work for other hardware variants. Will it yield the wrong plan, or will the plan's execution yield wrong results? I'm surprised because the SQL changes I proposed seemed relatively aligned with the existing extension source code which references support functions defined in code related to btree indexes (e.g. btint2cmp). These functions are already hardware-independent. Aren't these functions the ones called by the engine when executing a query and going through the index - as explained here (https://www.postgresql.org/docs/18/xindex.html#XINDEX-OPFAMILY)? Also there a specific reason the integer-related operator classes defined in btree_gin (int2_ops, int4_ops, int8_ops) don't belong to the same operator family? That seems to be the direction suggested by the documentation I linked to above. Finally, what is your approach to testing on 32-bit or big-endian hardware? Thank you for your guidance, Quentin On Fri, Jan 31, 2025, at 21:42, Tom Lane wrote: > "Quentin de Metz" writes: >> On a multi-column GIN index over a bigint column and a text column, the query planner does not filter the index on the bigint column when a condition on this column is specified with a number literal. > > Yeah, because "owner_id = 12" will use int84eq, which as you observe > is not supported by btree_gin's opclass. > >> Would you be open to considering a patch to include the ALTER OPERATOR snippet in the btree_gin install script, so that this works out of the box? > > I'd be quite surprised if that "just works" without any corresponding > changes in the C code, because btree_gin.c only knows about applying > same-type-on-both-sides comparison functions. (int8 vs int4 might > appear to work as long as you don't try very hard, but for example > it'd fail on 32-bit or big-endian hardware.) If you feel like writing > a patch that actually takes care of the matter fully, step right up. > > regards, tom lane