Re: Small optimization with expanding dynamic hash table

2025-07-11 Thread cca5507
Hi, The v3 patch attached. (Add some comment in commit msg) -- Regards, ChangAo Chen v3-0001-Small-optimization-with-expanding-dynamic-hash-ta.patch Description: Binary data

Re: Small optimization with expanding dynamic hash table

2025-07-11 Thread wenhui qiu
Hi > The v2 patch maybe more clear: > We can calc bucket just by hashvalue & high_mask when expanding table because the if condition in calc_bucket() must be false. I think you may add a comment to this path so that code reviewers can clearly see your optimization. Thanks On Thu, Jul 10, 2025 at

Re: Small optimization with expanding dynamic hash table

2025-07-09 Thread cca5507
Hi, The v2 patch maybe more clear: We can calc bucket just by hashvalue & high_mask when expanding table because the if condition in calc_bucket() must be false. -- Regards, ChangAo Chen v2-0001-Small-optimization-with-expanding-dynamic-hash-ta.patch Description: Binary data

Re: Small optimization with expanding dynamic hash table

2025-07-08 Thread cca5507
> One thing to note is that in this scenario, there is no safeguard if the hashvalue is 0x111 and new_bucket is 0x110. But the hash table is already corrupted if the hashvalue 0x111 in old_bucket 0x010, all hashvalue in old_bucket should have: hashvalue & low_mask == old_bucket's no. -- Regar

Re: Small optimization with expanding dynamic hash table

2025-07-08 Thread Rahila Syed
Hi, Yes, for example: >> >> low_mask: 0x011, high_mask: 0x111, old_bucket: 0x010, new_bucket: 0x110 >> >> The old_bucket's hash value like 0x***010 or 0x***110, the later is in >> the old_bucket is because we didn't have new_bucket before, so only hash >> value like 0x***110 needs relocation: hash

Re: Small optimization with expanding dynamic hash table

2025-07-08 Thread Rahila Syed
Hi, Yes, for example: > > low_mask: 0x011, high_mask: 0x111, old_bucket: 0x010, new_bucket: 0x110 > > The old_bucket's hash value like 0x***010 or 0x***110, the later is in the > old_bucket is because we didn't have new_bucket before, so only hash value > like 0x***110 needs relocation: hashvalue

Re: Small optimization with expanding dynamic hash table

2025-07-08 Thread cca5507
> Will this still work if new_bucket is not equal to hctl->low_mask + 1?Yes, for example: low_mask: 0x011, high_mask: 0x111, old_bucket: 0x010, new_bucket: 0x110 The old_bucket's hash value like 0x***010 or 0x***110, the later is in the old_bucket is because we didn't have new_bucket before,

Re: Small optimization with expanding dynamic hash table

2025-07-07 Thread Rahila Syed
Hi, > If I understand correctly, we only need to check the specific bit > to determine whether a hash element needs relocation: > > diff --git a/src/backend/utils/hash/dynahash.c > b/src/backend/utils/hash/dynahash.c > index 1ad155d446e..32fbae71995 100644 > --- a/src/backend/utils/hash/dynahash