From: Jan Behrens <jbe@public-software-group.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: GiST index on INT8, possible bug in query planner?
Date: Mon, 3 Dec 2018 18:28:31 +0100
Message-ID: <20181203182831.186d562e6b2b35e085e9ef21@public-software-group.org> (raw)
In-Reply-To: <31226.1543855637@sss.pgh.pa.us>
References: <20181203170904.3bebd803bd71f4a24a3e1061@public-software-group.org>
<31226.1543855637@sss.pgh.pa.us>
On Mon, 03 Dec 2018 11:47:17 -0500
Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Jan Behrens <jbe@public-software-group.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
You are right! I just tested it and ::int8 does the job.
It might be good to add a short notice or warning in the documentation
at: https://www.postgresql.org/docs/current/btree-gist.html
It might help other people who run into the same problem.
Thanks for helping me,
Jan Behrens
--
Public Software Group e. V.
Johannisstr. 12, 10117 Berlin, Germany
www.public-software-group.org
vorstand@public-software-group.org
eingetragen in das Vereinregister
des Amtsgerichtes Charlottenburg
Registernummer: VR 28873 B
Vorstände (einzelvertretungsberechtigt):
Jan Behrens
Axel Kistner
Andreas Nitsche
Björn Swierczek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: jbe@public-software-group.org, tgl@sss.pgh.pa.us
Subject: Re: GiST index on INT8, possible bug in query planner?
In-Reply-To: <20181203182831.186d562e6b2b35e085e9ef21@public-software-group.org>
References: <20181203170904.3bebd803bd71f4a24a3e1061@public-software-group.org> <31226.1543855637@sss.pgh.pa.us> <20181203182831.186d562e6b2b35e085e9ef21@public-software-group.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox