Repository navigation
10.1.0
Adds Database::estimateCount(string $collection): ?int, which reads a collection's row count from engine statistics instead of scanning it.
On Postgres it returns n_live_tup, which every commit updates. A standby collects no statistics, so it returns reltuples from the last vacuum or analyze instead. It returns null for never-analyzed or missing tables and for shared tables, whose statistics cover every tenant. Every other adapter returns null, so callers fall back to count(). Pool delegates it and ReadWritePool routes it as a read.
An exact COUNT on Postgres reads the whole heap once scattered writes clear the visibility map. On a 3M-row (3.5 GB) table, that was 3.5 GB read and 30 s of IO wait, against one block and 0.05 ms for the estimate.