BUG #17594: conditional hash indexes size (hash index ignore WHERE condition during CREATE INDEX?) - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #17594: conditional hash indexes size (hash index ignore WHERE condition during CREATE INDEX?)
Date
Msg-id 17594-fca95086967695be@postgresql.org
Whole thread Raw
Responses Re: BUG #17594: conditional hash indexes size (hash index ignore WHERE condition during CREATE INDEX?)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      17594
Logged by:          Maxim Boguk
Email address:      maxim.boguk@gmail.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


pgsql-bugs by date:

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