pub struct DbHealth {
pub page_count: u64,
pub freelist_count: u64,
pub page_size: u64,
pub free_percent: f64,
pub total_size_bytes: u64,
pub wasted_bytes: u64,
}Expand description
Database health metrics from PRAGMA introspection.
Contains page-level statistics useful for deciding whether to run
VACUUM. Does not derive Serialize — these are internal
infrastructure metrics that must not be exposed on unauthenticated
endpoints.
Fields§
§page_count: u64Total number of pages in the database.
freelist_count: u64Number of pages on the freelist (reclaimable by VACUUM).
page_size: u64Size of each page in bytes.
free_percent: f64Percentage of pages on the freelist (0.0–100.0).
total_size_bytes: u64Total database file size in bytes (page_count * page_size).
wasted_bytes: u64Wasted space in bytes (freelist_count * page_size).
Implementations§
Source§impl DbHealth
impl DbHealth
Sourcepub async fn collect(conn: &Connection) -> Result<Self>
pub async fn collect(conn: &Connection) -> Result<Self>
Collect health metrics via PRAGMA page_count, freelist_count,
page_size. Computes derived fields from those three values.
§Errors
Returns an error if any PRAGMA query fails or returns an unexpected value.
Sourcepub fn needs_vacuum(&self, threshold_percent: f64) -> bool
pub fn needs_vacuum(&self, threshold_percent: f64) -> bool
Returns true if free_percent >= threshold_percent.