Re: BUG #14087: btree_gin index doesn't work on INT with POSITIVE constraint

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: joris(dot)vandyck(at)promani(dot)be
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14087: btree_gin index doesn't work on INT with POSITIVE constraint
Date: 2016-04-15 21:09:16
Message-ID: 30984.1460754556@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

joris(dot)vandyck(at)promani(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message quassnoi 2016-04-15 21:36:14 BUG #14089: ON CONFLICT allows function variables in index expressions
Previous Message David G. Johnston 2016-04-15 20:54:21 Re: BUG #14088: pg_restore, --schema, causes TOC entries from even executing.