BUG #17594: conditional hash indexes size (hash index ignore WHERE condition during CREATE INDEX?)

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: maxim(dot)boguk(at)gmail(dot)com
Subject: BUG #17594: conditional hash indexes size (hash index ignore WHERE condition during CREATE INDEX?)
Date: 2022-08-25 20:19:54
Message-ID: 17594-fca95086967695be@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 17594
Logged by: Maxim Boguk
Email address: maxim(dot)boguk(at)gmail(dot)com
PostgreSQL version: 14.4
Operating system: Linux
Description:

Hi,

I found very weird situation with size of highly selective partial hash
indexes (they has almost same size as full table hash index).
Test case:

create table test_1000000 as select id from generate_series(1, 1000000) as
g(id);
create index test_1000000_hash_full_idx on test_1000000 using hash(id);
create index test_1000000_hash_partial_idx on test_1000000 using hash(id)
where id<11;
create table test_10 as select id from generate_series(1, 10) as g(id);
create index test_10_hash_full on test_10 using hash(id);

\di+ test_1*
List of relations
Schema | Name | Type | Owner | Table |
Persistence | Access method | Size | Description
--------+-------------------------------+-------+--------+--------------+-------------+---------------+-------+-------------
public | test_1000000_hash_full_idx | index | mboguk | test_1000000 |
permanent | hash | 32 MB |
public | test_1000000_hash_partial_idx | index | mboguk | test_1000000 |
permanent | hash | 28 MB |
public | test_10_hash_full | index | mboguk | test_10 |
permanent | hash | 80 kB |

Expected: the test_1000000_hash_partial_idx and test_10_hash_full indexes
should have same or at least close size because they index same amount of
rows (10):

select count(*) from test_10;
count
-------
10

select count(*) from test_1000000 where id<11;
count
-------
10

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2022-08-25 20:49:09 Re: BUG #17594: conditional hash indexes size (hash index ignore WHERE condition during CREATE INDEX?)
Previous Message PG Bug reporting form 2022-08-25 17:26:08 BUG #17593: min key size 112 bits from FIPS SP800-131 requirement for HMAC-SHA raises exception in SCRAM-SHA-256