[PATCH] Improve HASH overflow page reuse for better locality

  • Jump to comment-1
    lakshmi<lakshmigcdac@gmail.com>
    Apr 28, 2026, 6:47 AM UTC
    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