[PATCH] Improve HASH overflow page reuse for better locality
lakshmi <lakshmigcdac@gmail.com>
From: lakshmi <lakshmigcdac@gmail.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Kirill Reshke <reshkekirill@gmail.com>,
Robert Haas <robertmhaas@gmail.com>
Date: 2026-04-28T06:51:14Z
Lists: pgsql-hackers
Attachments
- 0001-hash-reuse-recently-freed-overflow-pages.patch (text/x-patch) patch 0001
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