From: Tom Lane <tgl@sss.pgh.pa.us>
To: Daniel Newman <dtnewman@gmail.com>
Cc: danielnewman@umich.edu, Robert Haas <robertmhaas@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14210: filter by "=" constraint doesn't work when hash index is present on a column
Date: Thu, 23 Jun 2016 19:08:57 -0400
Message-ID: <10331.1466723337@sss.pgh.pa.us> (raw)
In-Reply-To: <CALo0FatmGhupZU02+2WwN3v=rDoPuEkY_HhMQRhmfdQxerXA8Q@mail.gmail.com>
References: <20160623162507.17237.39471@wrigleys.postgresql.org>
<30648.1466701447@sss.pgh.pa.us>
<CALo0FatmGhupZU02+2WwN3v=rDoPuEkY_HhMQRhmfdQxerXA8Q@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Daniel Newman <dtnewman@gmail.com> writes:
> Yes. If i delete the index and recreate it, the bug is replicated.
So the answer is that this got broken by commit 9f03ca915196dfc8,
which appears to have imagined that _hash_form_tuple() is just an
alias for index_form_tuple(). But it ain't. As a result, construction
of hash indexes larger than shared_buffers is broken in 9.5 and up:
what gets entered into the index is garbage, because we are taking
raw data as if it were already hashed. (In fact, in this example,
we seem to be taking *pointers* to raw data as the hash values.)
> Interestingly, I modified the pg_dump file a bit. At the end, it says:
>> CREATE INDEX hash_issue_index ON hash_issue_table USING hash
>> (hash_issue_column);
>> DROP INDEX hash_issue_index;
>> CREATE INDEX hash_issue_index ON hash_issue_table USING hash
>> (hash_issue_column);
> This is because the issue was not replicating (for some reason) when it
> built the index the first time.
I think what's happening there is that the first CREATE INDEX
underestimates the size of the table and decides it doesn't need to
use the _h_spool() code path. The other path isn't broken.
We can either revert the aforesaid commit so far as it affects hash,
or do something to break _hash_form_tuple's encapsulation of the
hash-value-for-data substitution. I don't immediately see a non-messy
way to do the latter.
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
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, dtnewman@gmail.com, robertmhaas@gmail.com
Subject: Re: BUG #14210: filter by "=" constraint doesn't work when hash index is present on a column
In-Reply-To: <10331.1466723337@sss.pgh.pa.us>
References: <20160623162507.17237.39471@wrigleys.postgresql.org> <30648.1466701447@sss.pgh.pa.us> <CALo0FatmGhupZU02+2WwN3v=rDoPuEkY_HhMQRhmfdQxerXA8Q@mail.gmail.com> <10331.1466723337@sss.pgh.pa.us>
* 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