Re: Partial hash index is not used for implied qual.

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Partial hash index is not used for implied qual.
Дата
Msg-id CAApHDvpVwXQgiatD_FM_F3fYKU-j1kqPeTQn-xeRptc2nyGRVw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Partial hash index is not used for implied qual.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Tue, 25 Nov 2025 at 15:01, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Actually, after thinking a bit longer, it'd be better to do something
> like the attached so that we don't keep redundant quals unless they'd
> *all* be excluded.

I think your 1st patch was more along the correct lines. With the 2nd
one, I think you're maybe assuming that the non-empty newrestrictinfo
must contain an indexable qual, but the list we're working with at
that point is the rel's baserestrictinfo, which could contain a bunch
of stuff that'll never match to the index. If you continue to remove
the implied qual when there's a non-indexable base qual in the list,
then we'll still have the same issue that Sergei is trying to fix.
Just try adding an unrelated qual with your 2nd patch. Something like:
select * from hash_partial where x=1 and ctid >= '(0,0)';

I think you might have tried the 2nd method because you didn't see the
point in adding >1 indexable qual to scan the index with when we just
want ==1. If you wanted to do that, then maybe match_clause_to_index()
would be the place to ensure the list_length() doesn't go above 1 for
non-amoptionalkey indexes. Is that really worthwhile? hash indexes
only support equality anyway, so in what scenario would there be more
than 1 qual?

David



В списке pgsql-hackers по дате отправления: