Partial hash index is not used for implied qual.

From: Sergei Glukhov <s(dot)glukhov(at)postgrespro(dot)ru>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Partial hash index is not used for implied qual.
Date: 2025-11-24 07:32:18
Message-ID: e200bf38-6b45-446a-83fd-48617211feff@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

Partial hash index is not used if qual is an implied qual
since this qual is not added to indrestrictinfo and we cannot
get the keys needed to make hash index scan possible.
Suggested fix is to add implied qual for the indexes
which requires the presence of a key to scan the index.

How to repeat:

CREATE TABLE hash_partial(x) AS
       SELECT x as y from generate_series(1, 1000) as x;
ANALYZE hash_partial;
CREATE INDEX partial_idx ON hash_partial USING hash(x) WHERE x = 1;
EXPLAIN (COSTS OFF) SELECT x FROM hash_partial WHERE x = 1;
...
         QUERY PLAN
--------------------------
 Seq Scan on hash_partial
   Filter: (x = 1)
 ...

 Regards,
 Sergei Glukhov

Attachment Content-Type Size
partial_hash_index_with_implied_qual.patch text/x-patch 3.0 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2025-11-24 07:32:39 Re: Skipping schema changes in publication
Previous Message Bykov Ivan 2025-11-24 07:09:39 IPC/MultixactCreation on the Standby server