Re: GiST index on INT8, possible bug in query planner?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jan Behrens <jbe(at)public-software-group(dot)org>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: GiST index on INT8, possible bug in query planner?
Date: 2018-12-03 16:47:17
Message-ID: 31226.1543855637@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jan Behrens <jbe(at)public-software-group(dot)org> 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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jan Behrens 2018-12-03 17:28:31 Re: GiST index on INT8, possible bug in query planner?
Previous Message Kenneth Marshall 2018-12-03 16:28:36 Query never completes with an OR condition