Interface IMaintenanceProvider
Storage maintenance: planner statistics and index health. Born out of the 2026-09-10
incident where stale planner statistics after a bulk seed turned every plan into fiction
(a 30ms tree query ran for a second), and index health was visible only by hand-written
catalog queries per database.
Everything here is read-only except the two AnalyzeAsync overloads, and both are
explicit calls. Reorganising the storage (VACUUM, REINDEX, resetting counters) is not
offered on purpose (owner decision 2026-09-21): the facade reports what the database is
doing so an operator can hand the findings to a DBA, and a button that locks a production
table must not be one click away in a dashboard.
public interface IMaintenanceProvider
Methods
AnalyzeAsync(CancellationToken)
Refreshes the planner statistics of the database (PostgreSQL ANALYZE,
Task AnalyzeAsync(CancellationToken cancellationToken = default)
AnalyzeTableAsync(string, string?, CancellationToken)
Refreshes the planner statistics of ONE table (PostgreSQL ANALYZE t, MSSQL
Task AnalyzeTableAsync(string table, string? schema = null, CancellationToken cancellationToken = default)
GetIndexStatsAsync(CancellationToken)
Index statistics of the user tables, read from the database catalogs. Fields the
Task<IReadOnlyList<IndexStatistics>> GetIndexStatsAsync(CancellationToken cancellationToken = default)
GetStatisticsWindowAsync(CancellationToken)
Since when the usage counters of have been counting,
Task<StatisticsWindow> GetStatisticsWindowAsync(CancellationToken cancellationToken = default)
GetTableStatsAsync(CancellationToken)
Table statistics of the user tables: size, rows, the size of their indexes, and when
Task<IReadOnlyList<TableStatistics>> GetTableStatsAsync(CancellationToken cancellationToken = default)