From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: gentz@futuretap.com
Subject: BUG #15679: Partial HASH index takes too much space
Date: Fri, 08 Mar 2019 20:06:45 +0000
Message-ID: <15679-5e1b6086b202047c@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 15679
Logged by: Ortwin Gentz
Email address: gentz@futuretap.com
PostgreSQL version: 10.6
Operating system: Amazon RDS
Description:
I created a partial HASH index for a sparsely populated column:
CREATE INDEX partial_hash ON mytable USING HASH(my_id) WHERE my_ID IS NOT
NULL;
Even though the my_id VARCHAR(255) column is populated (NON NULL) only for a
few hundred records, the index takes 256 MB of space (for a table with > 10m
records). Also, it doesn't make a difference if the index is created as a
partial index ("WHERE my_ID IS NOT NULL") or as a full index.
In contrast to that, a BTREE index differs considerably in space for full
and partial:
CREATE INDEX full_btree ON mytable (my_id); # 543 MB
CREATE INDEX partial_btree ON mytable (my_id) WHERE my_ID IS NOT NULL; # 16
KB
See also this StackExchange conversation where user jjanes considers the
behavior a bug in the hash index code:
https://dba.stackexchange.com/a/231660/25337
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: noreply@postgresql.org, gentz@futuretap.com
Subject: Re: BUG #15679: Partial HASH index takes too much space
In-Reply-To: <15679-5e1b6086b202047c@postgresql.org>
References: <15679-5e1b6086b202047c@postgresql.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