bench/scan_cost.sh results

What one scan costs, on a catalog of a known size. Method: the script builds 1,000 tables in schema app, each with a primary key, a UNIQUE index, a CHECK constraint, a foreign key and a trigger, plus one breach (a disabled trigger) and one gap (a NOT VALID CHECK); then it times 20 calls inside one DO block, three times per function, on a throwaway server.

  • Date: 2026-11-12
  • Code: pg_promise_guard 0.2.10; bench/scan_cost.sh as committed in 2000d63.
  • PostgreSQL 13.23, built from REL_13_STABLE 05f6c9ec2c4, CFLAGS=-O2, no assertions, default settings except dynamic_shared_memory_type = mmap.
  • Catalog: 5,390 pg_class rows, 3,004 constraints, 5,000 triggers, 3,155 indexes.
  • Machine: AMD Ryzen AI 9 HX 370 (24 threads), 30 GiB RAM, Fedora, Linux 7.3.3; a desktop in use at the time, not an isolated benchmark host.
  • Command: PGHOST=<socket dir> PGPORT=<port> bash bench/scan_cost.sh
call per call, 3 repetitions
check_promises('app') 10.17, 10.37, 10.15 ms
promises_kept(), a breach present 10.20, 10.07, 10.33 ms
promises_kept(), no breach 10.36, 10.45, 9.82 ms

This backs the README’s “cheap enough to run every minute”, which had no measurement behind it. One machine’s numbers on one catalog: re-run the script on yours.