Skip to content

index prefetching #159

@grantzhou

Description

@grantzhou

--- As of 2026-02-09T22:44:11.000Z ---

Peter Geoghegan posted v10 of the index prefetching patch with two major improvements. First, the read stream callback (heapam_getnext_stream) now yields at key intervals to keep scans responsive, particularly beneficial for "ORDER BY ... LIMIT N" queries and merge joins. This involves complex trade-offs between responsiveness and maintaining adequate prefetch distance, with heuristics derived from adversarial benchmarking. Second, a new patch addresses the selfuncs.c problem where VISITED_PAGES_LIMIT is incompatible with the new table_index_getnext_slot interface. The solution adds IndexScanDescData.xs_read_extremal_only field for get_actual_variable_range, making nbtree stop after scanning one leaf page. This approach should solve existing VISITED_PAGES_LIMIT ineffectiveness issues, particularly when many index tuples have LP_DEAD bits set. Geoghegan plans to start a separate thread to discuss these issues further.

Peter Geoghegan发布了索引预取补丁的v10版本,包含两项主要改进。首先,读取流回调函数(heapam_getnext_stream)现在会在关键时刻让出控制权以保持扫描的响应性,这对"ORDER BY ... LIMIT N"查询和合并连接特别有益。这涉及响应性与维持足够预取距离之间的复杂权衡,使用了通过对抗性基准测试得出的启发式算法。其次,新补丁解决了selfuncs.c问题,即VISITED_PAGES_LIMIT与新的table_index_getnext_slot接口不兼容。解决方案为get_actual_variable_range添加了IndexScanDescData.xs_read_extremal_only字段,使nbtree在扫描一个叶页后停止。这种方法应该能解决现有的VISITED_PAGES_LIMIT无效性问题,特别是当许多索引元组设置了LP_DEAD位时。Geoghegan计划启动单独的讨论线程来进一步讨论这些问题。

participants - 参与者:

Metadata

Metadata

Assignees

No one assigned

    Labels

    hacker discussionshacker discussions summarized by PGNexus Agent

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions