Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gTrNS-0001Ca-Vi for pgsql-general@arkaria.postgresql.org; Mon, 03 Dec 2018 16:47:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gTrNR-0007Id-KX for pgsql-general@arkaria.postgresql.org; Mon, 03 Dec 2018 16:47:21 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gTrNR-0007IM-Bs for pgsql-general@lists.postgresql.org; Mon, 03 Dec 2018 16:47: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_SHA1:256) (Exim 4.89) (envelope-from ) id 1gTrNP-0007b8-BL for pgsql-general@lists.postgresql.org; Mon, 03 Dec 2018 16:47: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 wB3GlHn8031227; Mon, 3 Dec 2018 11:47:17 -0500 From: Tom Lane To: Jan Behrens cc: pgsql-general@lists.postgresql.org Subject: Re: GiST index on INT8, possible bug in query planner? In-reply-to: <20181203170904.3bebd803bd71f4a24a3e1061@public-software-group.org> References: <20181203170904.3bebd803bd71f4a24a3e1061@public-software-group.org> Comments: In-reply-to Jan Behrens message dated "Mon, 03 Dec 2018 17:09:04 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <31225.1543855637.1@sss.pgh.pa.us> Date: Mon, 03 Dec 2018 11:47:17 -0500 Message-ID: <31226.1543855637@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Jan Behrens writes: > However, the GiST index seems not to work as expected by me when > 64-bit integers are involved. I tried to create a minimal > proof-of-concept to demonstrate this. Consider the following setup: > CREATE TABLE test8_gist (id SERIAL4, ctx INT8); > CREATE INDEX ON test8_gist USING gist (ctx, id); > EXPLAIN SELECT * FROM test8_gist WHERE ctx = 1 AND id = 2; > -- uses Index Cond: (id = 2) > The query planning for the select on table "test8_gist" does not > include "ctx" in the "Index Cond". Probably it would if you'd written "WHERE ctx = 1::int8". Without the cast, what you'll have is "int8 = int4", and I suspect that btree_gist doesn't include cross-type operators in its opclasses. regards, tom lane