# PostgreSQL index-only scan coverage

Controlled software observation, not a corruption test or storage benchmark.
The probe creates its own disposable PostgreSQL cluster and accepts no connection
string or existing data directory. Run as an unprivileged user with PostgreSQL 16
and the pg_visibility extension installed. No TCP listener is enabled.

```sh
python3 probe.py --output replay.json
python3 -B verify_record.py replay.json
python3 -B -m unittest -v test_probe.py
```

The default binary directory is /usr/lib/postgresql/16/bin; --bindir selects another
server installation; --client-bin selects the matching psql directory. Only the recorded 16.15 build is covered by the published results.
Each invocation creates a fresh cluster with checksums enabled, 256 integer keys,
a B-tree primary-key index and a 64-character nonindexed text column. The table
uses fillfactor 70. Autovacuum is disabled only inside the disposable cluster.

Stages: insert; VACUUM (ANALYZE); commit a same-length change to the nonindexed
column for id=1; VACUUM (ANALYZE) again. Each SQL invocation is its own completed
transaction. No long-lived snapshot or competing writer is present.
The planner settings discourage sequential and bitmap scans and disable parallel
execution and JIT. The actual plan must be a single Index Only Scan with one loop.

The instrumented SELECT returns only id, ordered by id. EXPLAIN ANALYZE discards
query output; the recorded keys come from a separately executed SELECT after
EXPLAIN. It verifies the ordered keys, not the payload column. VM summaries are
collected before and after EXPLAIN. Heap Fetches counts visibility-fetch attempts
for index TIDs, not unique pages, bytes, successful rows or physical device reads.
All-visible page counts have a different denominator: main-relation heap pages.

The oracle checks >0, 0, >0, 0 fetches and the corresponding visibility-map state.
Exact nonzero counts are observations, not portability requirements. A nonindexed
update is not assumed to be HOT. No performance or detection-rate conclusion is
drawn; the original TOAST mutation dataset is separate and unchanged.

results-1.json through results-3.json preserve three fresh-cluster executions on
one host, including SQL, full plans, settings and executable/probe SHA-256 hashes.
Repetition checks reproducibility, not statistical uncertainty or independent review.
The source-review record and content tests document the publication mapping.

Primary sources, accessed 2026-10-21:
- https://www.postgresql.org/docs/16/indexes-index-only-scans.html
- https://www.postgresql.org/docs/16/storage-vm.html
- https://www.postgresql.org/docs/16/pgvisibility.html
- https://www.postgresql.org/docs/16/using-explain.html
- https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/executor/nodeIndexonlyscan.c
- https://github.com/postgres/postgres/blob/7d3e000c5961a544302072058a1184e9a588837b/src/backend/commands/explain.c

Referenced PostgreSQL code and manuals remain under their own licenses and are
linked, not redistributed here.

## Release review, 2026-10-22

The original probe and three captures are unchanged. Run 4 repeats the same
probe in another fresh disposable cluster during release review.
Use verify_record.py for the stronger acceptance check: it binds summaries to
the ordered SQL transcript, rejects failed commands, checks startup/shutdown,
validates integer counters and checks the probe source hash.
The original probe's internal verify_run checks stage transitions only.
The tests now use the stronger verifier. A self-consistent capture is not
cryptographic proof that execution occurred; reproducibility still requires
running the probe. This verifier neither connects to a database nor runs SQL.
