pub async fn db_size_bytes(pool: &SqlitePool) -> Result<i64>Expand description
The used size of the SQLite database, in bytes, computed as
(page_count - freelist_count) * page_size. Backs the DB-size watermark that
disables new polling.
Subtracting the freelist is what keeps the watermark from latching the poller
off: page_count counts pages the file has allocated, including ones freed
by a DELETE but not yet returned to the OS (SQLite keeps them on a freelist
for reuse and never shrinks the file without a VACUUM). Counting only the
live pages means a retention prune (which frees pages, see reclaim) is
actually reflected here, so the watermark can drop back below its threshold
and polling resumes. Cheap (three PRAGMA reads); works for file + :memory:.