Re: Hash-based MCV matching for large IN-lists

Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>

From: Ilia Evdokimov <ilya.evdokimov@tantorlabs.com>
To: Tatsuya Kawata <kawatatatsuya0913@gmail.com>, David Geier <geidav.pg@gmail.com>
Cc: Chengpeng Yan <chengpeng_yan@outlook.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2026-02-18T12:48:36Z
Lists: pgsql-hackers

Attachments

I've fixed all the comments raised above and updated the v5 patch.


On 2/7/26 10:42, Tatsuya Kawata wrote:
> I initially considered consolidating this by checking for NULL 
> elements before building the hash table, but realized this would add 
> an extra loop in the common case where there are no NULLs.

Thanks for that suggestion. We can check for NULL elements without an 
explicit loop by using memchr(), so there's no need for an additional 
building of hash table. I'll update patch with it.

That said, I think it might be better to continue this small 
optimization with NULL for constant arrays separately in another thread. 
It's cleaner to split this work into smaller, focused changes rather 
than mixing everything into single patch


If anything is still unclear in the code or insufficiently documented, 
or if you have other suggestions, please do not hesitate to point them out.

--
Best regards.
Ilia Evdokimov,
Tantor Labs LLC,
https://tantorlabs.com/

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Short-circuit row estimation in NOT IN containing NULL consts