Hi Bertrand,
Thank you for the patch. I tested v1 (0001 and 0002) and it looks good to
me.
What I did:
- Applied both patches to current master (165af118c5). They apply cleanly
and build without warnings (--enable-cassert --enable-debug
--enable-tap-tests).
- make check passes (243 tests). The whole src/test/modules/test_misc
suite passes with the patch (16 files, 169 tests), including the new
t/016_heap_rescan_strategy.pl.
- I also ran the new test against unpatched master. It fails there on
"a rescanned sequential scan uses its newly selected bulk-read strategy"
(got 0, expected > 0). So the test does catch the bug, which I think
helps with the question of whether it is worth its setup cost.
- I ran the query from the test by hand (shared_buffers = 1MB,
max_parallel_workers_per_gather = 0) and looked at
pg_stat_get_backend_io() for the bulkread context:
- master: 0 reads, 0 hits in bulkread, with io_method = worker and
io_method = sync.
- patched: 468 reads, 104 hits in bulkread, with both io_method values.
The query returns the same 11997 rows in both builds, and there were no
assertion failures or errors in the server log.
One small thing: the commit message of 0001 has an empty "Reviewed-by:"
and "Discussion: https://postgr.es/m/" without the message-id. I guess you
will fill those in later.
I only tested the case where the rescan starts using a strategy. I did not
exercise the other direction (the strategy is disabled on rescan, the
extension case you described), and I did not test parallel, bitmap or TID
range scans, io_uring, the back branches, or a meson build.
Thanks again,
Joao Rito