On Wed, May 15, 2019 at 11:54 AM Andres Freund <andres@anarazel.de> wrote:
Attached is a prototype of a variation of this. I added a table_tuple_tid_valid(TableScanDesc sscan, ItemPointer tid) callback / wrapper. Currently it just takes a "plain" scan, but we could add a separate table_beginscan variant too.
For heap that just means we can just use HeapScanDesc's rs_nblock to filter out invalid tids, and we only need to call RelationGetNumberOfBlocks() once, rather than every table_tuple_tid_valid(0 / table_get_latest_tid() call. Which is a good improvement for nodeTidscan's table_get_latest_tid() call (for WHERE CURRENT OF) - which previously computed the relation size once per tuple.
Question on the patch, if not too late
Why call table_beginscan() in TidNext() and not in ExecInitTidScan() ? Seems cleaner to have it in ExecInitTidScan().