[PATCH] Improve HASH overflow page reuse for better locality

From: lakshmi <lakshmigcdac(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: [PATCH] Improve HASH overflow page reuse for better locality
Date: 2026-04-28 06:51:14
Message-ID: CAEvyyTj7oUqzh4sKpSm3urV1=kKO6TtdRucBFSD0Z6w_g1Ot+w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

Based on the suggestion in the previous discussion [1], I am starting a
separate thread to propose this as an enhancement.

While testing the HASH index build improvements, I worked on a follow-up
change to improve overflow page reuse. Currently, any free overflow page
may be reused, which can scatter overflow chains and affect cache locality.
This patch introduces a simple improvement where recently freed overflow
pages are preferred during allocation.

The change is backend-local and affects only page allocation. It does not
introduce any WAL changes or modify the on-disk format.

I have verified correctness using index build, drop, and VACUUM cycles.
Initial checks also confirm that WAL behavior remains unchanged.

I am currently working on collecting detailed performance results,
including both favorable and unfavorable scenarios, and will share them
shortly in this thread.

The patch is attached for review. Feedback and suggestions are welcome.

Regards,
Lakshmi G

reference

[1]
https://www.postgresql.org/message-id/flat/CALdSSPgu6fnoOYzgiFF4_Etr96zEHvSwvYJDemc3o%2B%2BEZbUQMA%40mail.gmail.com

Attachment Content-Type Size
0001-hash-reuse-recently-freed-overflow-pages.patch text/x-patch 3.4 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2026-04-28 06:57:17 Re: Support logical replication of DDLs, take2
Previous Message vignesh C 2026-04-28 06:34:35 Re: StringInfo fixes, v19 edition. Plus a few oddities