Re: BUG #14087: btree_gin index doesn't work on INT with POSITIVE constraint - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #14087: btree_gin index doesn't work on INT with POSITIVE constraint
Date
Msg-id 30984.1460754556@sss.pgh.pa.us
Whole thread Raw
In response to BUG #14087: btree_gin index doesn't work on INT with POSITIVE constraint  (joris.vandyck@promani.be)
List pgsql-bugs
joris.vandyck@promani.be writes:
> It seems like the choice between using the full index (first case with
> integer) or using the index partly and then filtering manually (second case
> with smallint) should not depend on whether the random_id is defined as
> integer or smallint.

The reason for the plan change is that if "random_id" is smallint, then
"random_id > 11422" is a cross-type operator (int2 > int4), and btree_gin
lacks support for such operators.  Fixing that is probably just a Small
Matter Of Programming, but I doubt it's very high on anyone's to-do list.
In the meantime, you might consider casting the comparison constant to
int2 explicitly if you want to make "random_id" be smallint; that is,
"random_id > 11422::smallint" would be indexable.

            regards, tom lane

pgsql-bugs by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: BUG #14088: pg_restore, --schema, causes TOC entries from even executing.
Next
From: quassnoi@gmail.com
Date:
Subject: BUG #14089: ON CONFLICT allows function variables in index expressions