Re: [PATCH] Use streaming read I/O in sample scans

From: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: Yuhang Qiu <iamqyh(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Melanie Plageman <melanieplageman(at)gmail(dot)com>
Subject: Re: [PATCH] Use streaming read I/O in sample scans
Date: 2026-11-03 06:42:51
Message-ID: aumCa/LSd3Nk2U6U@bdtpg
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thu, Aug 27, 2026 at 05:31:21PM +0300, Nazir Bilal Yavuz wrote:
> I started reviewing the patches, but it will take some time.
> Meanwhile, I think the initscan() strategy changes in 0001 and 0002
> fix an independent bug and could be committed separately. Melanie is
> CCed since she may know more. Bug:
>
> heap_beginscan() creates a read stream using the current
> scan->rs_strategy. On rescan, initscan() recalculates strategy
> eligibility and may allocate or free the strategy if the relation
> crosses the NBuffers / 4 threshold. However, the reused read stream
> retains the original scan->rs_strategy. This can cause the stream to
> either keep using no strategy after one is allocated or retain a
> dangling pointer after one is freed.

FWIW I also observed the same issue while working on another thread [1]. I created
a dedicated thread [2] for better visibility proposing a different approach than
Yuhang's one.

[1]: https://postgr.es/m/auCYYbDyrQEwIsQq%40bdtpg
[2]: https://postgr.es/m/aumB7BHGWewR4x/S(at)bdtpg

Regards,

--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2026-11-03 06:46:04 Re: PL/pgSQL: apply the too_many_rows extra check to EXECUTE ... INTO
Previous Message Bertrand Drouvot 2026-11-03 06:40:44 Fix ReadStream handling when heap rescan strategy changes