ctidscan
ctidscan · Example custom scan provider for CTID range predicates.
Overview
Usage
Sources:
ctidscan is a headless custom-scan demo that adds a planner path for heap scans constrained by ctid inequalities or ranges. It has no extension SQL and should be loaded only in sessions used to study physical tuple-range scans.
Core Workflow
The planner extracts lower and upper ctid bounds and starts or stops the heap scan around the corresponding blocks. Compare plans and results with SET enable_ctidscan = off when evaluating the custom path.
Objects and Configuration
LOAD 'ctidscan'initializes the module for the current backend.enable_ctidscanenables or disables its planner path.- The module emits informational start/end messages while executing the custom scan.
The README also shows shared_preload_libraries = 'ctidscan', but recommends local loading so the prototype does not affect unrelated users. A server restart is required after changing shared_preload_libraries.
Safety and Compatibility
A ctid is a physical tuple address, not a durable row identifier. It can change after UPDATE, VACUUM FULL, CLUSTER, or any table rewrite; never store it as an application key or use an old value to authorize or mutate a row.
The implementation copies executor structures and uses heap APIs from the PostgreSQL 9.x era. It has no current compatibility matrix and can break across major versions. Treat ctidscan as planner-extension sample code, validate correctness against a normal scan, and do not preload it on production clusters.