Hi Nazir,

> Thanks, 0001 and 0002 LGTM.

Thanks for the review. Attached is v3. Compared with v2:

- 0001 now clamps the current look-ahead distances and those saved for
  resuming a paused stream when changing to a strategy with a smaller
  pin limit.
- In 0003, I moved `stream_flags` into the block that uses it and removed
  the temporary `blockno` variable.
- 0002 and 0004 are unchanged.

> I am also not yet convinced that changing the documentation is
> sufficient for `SYSTEM_TIME`. It would be useful to get more opinions
> on whether that change is acceptable or whether `SYSTEM_TIME` should
> avoid to use read streams.

For `SYSTEM_TIME`, I compared the read-stream patch with the unpatched
base using:
```sql
SELECT count(*) FROM wide TABLESAMPLE system_time(100);
```

The table was 1 GiB, with one row per page. I used `shared_buffers=2GB`,
`io_combine_limit=128kB` and `debug_io_direct=data`, evicting the table from
shared buffers before each query. Worker mode used two I/O workers.

Each entry is the median execution time of five `EXPLAIN ANALYZE` runs:
```
io_method  effective_io_concurrency  Unpatched (ms)  Patched (ms)
worker                           16          100.14        100.83
worker                          256          100.11        103.23
sync                             16          100.08        101.51
sync                            256          100.11        123.31
io_uring                         16          100.10        100.17
io_uring                        256          100.10        100.19
```

As you noted, pages selected before the deadline can still be read and
processed afterwards. I'd like to hear what you and others think about
this change to `SYSTEM_TIME`.

Regards,
Yuhang Qiu

Attachment: v3-0001-read_stream-Allow-changing-the-buffer-access-stra.patch
Description: Binary data

Attachment: v3-0002-heapam-Keep-read-stream-strategy-in-sync-on-resca.patch
Description: Binary data

Attachment: v3-0003-heapam-Use-streaming-read-I-O-in-sample-scans.patch
Description: Binary data

Attachment: v3-0004-explain-Report-streaming-I-O-statistics-for-sampl.patch
Description: Binary data

Reply via email to