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 1tdxro-00B35F-Lv for pgsql-novice@arkaria.postgresql.org; Fri, 31 Jan 2025 20:43:57 +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 1tdxqo-002XSE-Oq for pgsql-novice@arkaria.postgresql.org; Fri, 31 Jan 2025 20:42:54 +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 1tdxqo-002XS6-GN for pgsql-novice@lists.postgresql.org; Fri, 31 Jan 2025 20:42:54 +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.96) (envelope-from ) id 1tdxqm-002WMr-1J for pgsql-novice@postgresql.org; Fri, 31 Jan 2025 20:42:53 +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 50VKgn4O4037727; Fri, 31 Jan 2025 15:42:50 -0500 From: Tom Lane To: "Quentin de Metz" cc: pgsql-novice@postgresql.org Subject: Re: btree_gin, bigint and number literals In-reply-to: <58782480-ab75-4416-a177-ccf91be288a9@app.fastmail.com> References: <58782480-ab75-4416-a177-ccf91be288a9@app.fastmail.com> Comments: In-reply-to "Quentin de Metz" message dated "Fri, 31 Jan 2025 18:02:13 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4037725.1738356169.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 31 Jan 2025 15:42:49 -0500 Message-ID: <4037726.1738356169@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "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 condit= ion on this column is specified with a number literal. Yeah, because "owner_id =3D 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 s= nippet 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