On Wed, Apr 3, 2024 at 4:28 PM Thomas Munro <thomas.mu...@gmail.com> wrote: > > On Thu, Apr 4, 2024 at 6:03 AM Melanie Plageman > <melanieplage...@gmail.com> wrote: > > On the topic of BAS_BULKREAD buffer access strategy, I think the least > > we could do is add an assert like this to read_stream_begin_relation() > > after calculating max_pinned_buffers. > > > > Assert(GetAccessStrategyBufferCount(strategy) > max_pinned_buffers); > > > > Perhaps we should do more? I think with a ring size of 16 MB, large > > SELECTs are safe for now. But I know future developers will make > > changes and it would be good not to assume they will understand that > > pinning more buffers than the size of the ring effectively invalidates > > the ring. > > Yeah I think we should clamp max_pinned_buffers if we see a strategy. > What do you think about: > > if (strategy) > { > int strategy_buffers = GetAccessStrategyBufferCount(strategy); > max_pinned_buffers = Min(strategy_buffers / 2, max_pinned_buffers); > } > > I just don't know where to get that '2'. The idea would be to > hopefully never actually be constrained by it in practice, except in > tiny/toy setups, so we can't go too wrong with our number '2' there.
Yea, I don't actually understand why not just use strategy_buffers - 1 or something. 1/2 seems like a big limiting factor for those strategies with small rings. I don't really think it will come up for SELECT queries since they rely on readahead and not prefetching. It does seem like it could easily come up for analyze. But I am on board with the idea of clamping for sequential scan/TID range scan. For vacuum, we might have to think harder. If the user specifies buffer_usage_limit and io_combine_limit and they are never reaching IOs of io_combine_limit because of their buffer_usage_limit value, then we should probably inform them. - Melanie