model-writtenrun 6876 - may be wrong, links go to the source messages. Commit-by-commit LLM analysis is in the Commits dialog.
- Tomas Vondra proposed exposing ReadStream prefetch distance, request size, concurrency, and stalls through EXPLAIN (IO), initially collecting counters unconditionally and retrieving them through new table-AM callbacks #1.
- Lukas Fittl tested the proposal and supplied an alternative using stack-based IOUsage instrumentation, which could also support utility commands and aggregate statistics #2; Tomas was reluctant to depend on that larger project near feature freeze and questioned how it would distinguish multiple streams within one scan #7.
- Melanie Plageman identified duplicate statistics structures, double-counted synchronous stalls, missed fast-path I/O, and hidden worker statistics, supplying fixes that Tomas incorporated without other changes #3 #8.
- Andres Freund proposed keeping statistics in scan descriptors instead of adding table-AM callbacks #9, and Tomas adopted that architecture, consolidated the structures, added TidRangeScan support, and temporarily enabled IO by default #13.
- Lukas supplied fixes for unstable regression output and missing zero-valued non-text fields #14; Tomas reorganized the implementation into infrastructure with BitmapHeapScan support, SeqScan support, and TidRangeScan support #15.
- Tomas then used a beginscan-flags prerequisite to allocate statistics only for instrumented scans, flattened non-text output, and added the number of I/O requests to make average sizes interpretable #16.
- Andres's review prompted null-pointer fixes, clearer waits terminology, an inline accumulation helper, unaligned regression output, and improved placement of parallel instrumentation metadata #17 #19 #22.
- Andres's WaitReadBuffers prerequisite, carried here in #19, landed as 513374a47a; the supplied cross-thread evidence attributes its latest matching submission to #999527 in the index-prefetch thread thread #47973, superseding both this thread's earlier attachment and #999508 in thread #139184.
- With the prerequisites committed, Tomas submitted the remaining series using read_stream_enable_stats(), but FreeBSD testing with debug_parallel_query=regress exposed missing instrumentation for non-parallel-aware workers and an existing BitmapHeapScan statistics bug #26.
- Tomas added a standalone BitmapHeapScan fix, folded in equivalent SeqScan and TidRangeScan fixes, and simplified worker output through ExplainOpenWorker/ExplainCloseWorker, while expressing concern about the resulting initialization complexity #27.
- Melanie proposed allocating instrumentation and parallel-aware state in separate DSM chunks with different TOC keys, implemented the pattern for index scans and the three affected table-scan nodes, and supplied a replacement series #28.
- Tomas supported the clearer DSM design after examining its overhead #31, and Melanie extracted the index/index-only prerequisite, retained small duplicated helpers, and added a duplicate-key assertion #33 #34.
- Melanie committed the assertion as 43222b8e53 with its check moved earlier in shm_toc_insert(), then committed the index DSM refactoring as dd78e69cfc with stricter worker lookup behavior; both came from #34.
- Although the motivating index-prefetch feature would miss PostgreSQL 19, Tomas and Melanie agreed that instrumentation for the existing ReadStream scans remained worthwhile #35 #36.
- After the index refactoring landed, Melanie posted the remaining BitmapHeapScan fix and a correction for omitted overflow-safe size arithmetic in index instrumentation #36.
- Tomas incorporated those fixes, changed IO back to default OFF to avoid cluttering EXPLAIN, added auto_explain.log_io, and introduced INSTRUMENT_IO so counters were collected only when requested #37.
- Lukas reviewed the two prerequisite fixes, the unaligned tests, infrastructure, and auto_explain support, while questioning the scope of the I/O labels and why cached scans still showed prefetch distances #38 #39; Tomas explained that ReadStream also supplies cached buffers and retained the existing labels #40.
- Tomas committed Melanie's BitmapHeapScan fix as 9c18b47e61 and arithmetic fix as 884f9b3c76, both unchanged from their attachments in #37; the BitmapHeapScan commit explicitly deferred backpatching because older branches needed a less invasive implementation.
- The remaining series fixed simultaneous WAL/IO enablement and instrumentation checks #41, then incorporated Melanie's cleanup, sizing, and DSM-lookup review plus corrected synchronous-read wait counting #43 #44 #46.
- Andres confirmed that synchronous reads must count as waits #47, and Melanie skimmed and accepted the final series #48.
- From #46, Tomas committed the unchanged unaligned tests as 10d5a12a93 and the infrastructure as 681daed931, adding a null-stream guard and refining documentation and comments in the latter.
- The remaining attachments in #46 landed unchanged as auto_explain support 61c36a34a4, SeqScan support 3b1117d6e2, and TidRangeScan support e157fe6f76, after which Tomas confirmed the entire feature series was committed #49.
- In May, Tomas proposed expanding the sparse IO documentation and fixing a typo #51; Lukas requested explanations of individual counters and explicit coverage limits, which Tomas agreed to consider #52 #53, but the supplied candidates contain no corresponding documentation commit.
- In September, Nikolay Samokhvalov reported that read_stream_reset() drain operations inflated prefetch averages and maxima, supplying a patch and tests that preserved those counters while retaining actual I/O accounting #54.
- Tomas and Andres stressed that issued I/O must remain counted, while Peter Geoghegan pointed to separate experimental work that avoids waiting during reset #55 #56 #57; Nikolay clarified that his question concerned consumer-prefetch statistics rather than issued I/O #58.
- The thread ends with the main feature landed, no demonstrated landing of the documentation or reset-statistics follow-ups, and Tomas acknowledging that the consumer-counting comment was misleading and promising to consider clarification #59.