| From: | cca5507 <cca5507(at)qq(dot)com> |
|---|---|
| To: | pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | A small problem when rehashing catalog cache |
| Date: | 2025-12-16 11:16:20 |
| Message-ID: | tencent_9EA10D8512B5FE29E7323F780A0749768708@qq.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
When we search catalog cache, we move the searched tuple to the front of the list:
```
/*
* We found a match in the cache. Move it to the front of the list
* for its hashbucket, in order to speed subsequent searches. (The
* most frequently accessed elements in any hashbucket will tend to be
* near the front of the hashbucket's list.)
*/
dlist_move_head(bucket, &ct->cache_elem);
```
If I understand correctly, we reverse the list in RehashCatCache() and RehashCatCacheLists():
```
/* Move all entries from old hash table to new. */
for (i = 0; i < cp->cc_nbuckets; i++)
{
dlist_mutable_iter iter;
dlist_foreach_modify(iter, &cp->cc_bucket[i])
{
CatCTup *ct = dlist_container(CatCTup, cache_elem, iter.cur);
int hashIndex = HASH_INDEX(ct->hash_value, newnbuckets);
dlist_delete(iter.cur);
dlist_push_head(&newbucket[hashIndex], &ct->cache_elem);
}
}
```
Maybe "dlist_push_head" -> "dlist_push_tail"? Thoughts?
--
Regards,
ChangAo Chen
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Dagfinn Ilmari Mannsåker | 2025-12-16 11:16:47 | Re: [PATCH]Remove the redundant assignment |
| Previous Message | Nitin Jadhav | 2025-12-16 10:55:37 | Change checkpoint‑record‑missing PANIC to FATAL |