Skip to main content

should_auto_vacuum

Function should_auto_vacuum 

Source
pub fn should_auto_vacuum(pager: &Pager, threshold: f32) -> Result<bool>
Expand description

Returns true if the on-disk freelist (counting both leaf and trunk pages — they’re all reclaimable bytes) exceeds threshold of header.page_count, i.e. the file is bloated enough to be worth compacting. Returns false for tiny databases (under MIN_PAGES_FOR_AUTO_VACUUM) and for empty freelists, both as fast paths to keep the auto-VACUUM hook cheap on the common case.

This is a read-only inspection of the pager’s current header and freelist chain — it does not mutate any state. The caller is responsible for actually invoking crate::sql::pager::vacuum_database when this returns true.