pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix unexpected reversal of lists during catcache rehash
Date: Wed, 07 Jan 2026 08:53:17 +0000
Message-ID: <E1vdPI4-0054B5-12@gemulon.postgresql.org> (raw)

Fix unexpected reversal of lists during catcache rehash

During catcache searches, the most-recently searched entries are kept at
the head of the list to speed up subsequent searches, keeping the
"freshest" entries at its beginning.  A rehash of the catcache was doing
the opposite: fresh entries were moved to the tail of the newly-created
buckets, causing a rehash to slow down a bit.

When a rehash is done, this commit switches the code to use
dlist_push_tail() instead of dlist_push_head(), so as fresh entries are
kept at the head of the lists, not their tail.

Author: ChangAo Chen <cca5507@qq.com>
Reviewed-by: John Naylor <johncnaylorls@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/tencent_9EA10D8512B5FE29E7323F780A0749768708@qq.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/68119480a763d761a9cf2413f4320d9a5d4b34d5

Modified Files
--------------
src/backend/utils/cache/catcache.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)



Message-ID: <E1vdPI4-0054B5-12@gemulon.postgresql.org>
Permalink:  ../E1vdPI4-0054B5-12@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vdPI4-0054B5-12@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix unexpected reversal of lists during catcache rehash
  In-Reply-To: <E1vdPI4-0054B5-12@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox