Re: btree_gin, bigint and number literals

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Quentin de Metz" <quentin(at)de(dot)me(dot)tz>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: btree_gin, bigint and number literals
Date: 2025-01-31 20:42:49
Message-ID: 4037726.1738356169@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

"Quentin de Metz" <quentin(at)de(dot)me(dot)tz> 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

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Laurenz Albe 2025-01-31 23:42:50 Re: Regarding setClob and getclobval methods in PostgreSQL
Previous Message Quentin de Metz 2025-01-31 17:02:13 btree_gin, bigint and number literals