Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1arB05-00053i-Bi for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Apr 2016 21:10:01 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1arB04-0007qK-VC for pgsql-bugs@arkaria.postgresql.org; Fri, 15 Apr 2016 21:10:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1arAzR-0006Ok-4C for pgsql-bugs@postgresql.org; Fri, 15 Apr 2016 21:09:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1arAzO-0000xm-Io for pgsql-bugs@postgresql.org; Fri, 15 Apr 2016 21:09:20 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id u3FL9GFN030985; Fri, 15 Apr 2016 17:09:16 -0400 From: Tom Lane To: joris.vandyck@promani.be cc: pgsql-bugs@postgresql.org Subject: Re: BUG #14087: btree_gin index doesn't work on INT with POSITIVE constraint In-reply-to: <20160415185902.22924.77993@wrigleys.postgresql.org> References: <20160415185902.22924.77993@wrigleys.postgresql.org> Comments: In-reply-to joris.vandyck@promani.be message dated "Fri, 15 Apr 2016 18:59:02 -0000" Date: Fri, 15 Apr 2016 17:09:16 -0400 Message-ID: <30984.1460754556@sss.pgh.pa.us> X-Pg-Spam-Score: -2.9 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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 -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs