feat(settings): Settings → System shows table sizes and what the last cleanup removed (#5469)
CI / lint (push) Successful in 2s
CI / integration (push) Successful in 1m12s
CI / unit (push) Successful in 1m28s
CI / publish (push) Successful in 1m4s

#5469 "Settings → System: table sizes and what the last cleanup removed".

- Storage: each table's size on disk (pg_total_relation_size, indexes and TOAST
  included) and Postgres's row estimate (reltuples), largest first, the 15
  largest by name and the rest summed, under the database's total size. Read
  from the catalog only, never by counting rows.
- Last cleanup: when it ran, how long it took, and what each pass removed (each
  aged table, run log files, the metric and Docker rollups, the log ring), or
  "Nothing was past its window". run_cleanup now returns that summary and keeps
  it as the cleanup.last_run setting, as reports.last_sent_at does; cleanup_secs
  (#5467) is recorded from the same figure.
- A hint links to where each retention window is set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-09 14:29:55 -04:00
co-authored by Claude Opus 5.5
parent a81b578247
commit 0b2fbf13fc
8 changed files with 227 additions and 30 deletions
+48
View File
@@ -38,4 +38,52 @@
<p class="field-hint" style="margin-top:0.75rem;">
Recorded each minute (the cleanup each hour). Any of these can be watched by an
<a href="/alerts/rules/new">alert rule</a>: pick the source "Steward itself".</p>
{# Storage (#5469): Postgres's own figures for each table, then what the
hourly cleanup last removed. Read from the catalog, never by counting. #}
<h2 class="section-title" style="margin:2rem 0 0.5rem;">Storage</h2>
<p class="field-hint" style="margin:0 0 1rem;">The database takes {{ storage.total|bytes }} on disk.</p>
<div class="card-flush">
<table class="table">
<thead><tr><th>Table</th><th class="num">On disk</th><th class="num">Rows (estimate)</th></tr></thead>
<tbody>
{% for t in storage.tables %}
<tr>
<td class="cell-name"><span title="{{ t.name }}">{{ t.name }}</span></td>
<td class="num nowrap">{{ t.bytes|bytes }}</td>
<td class="num nowrap">{% if t.rows is not none %}{{ "{:,}".format(t.rows) }}{% else %}—{% endif %}</td>
</tr>
{% endfor %}
{% if storage.rest.count %}
<tr><td class="tone-dim">+{{ storage.rest.count }} smaller tables</td>
<td class="num nowrap tone-dim">{{ storage.rest.bytes|bytes }}</td><td></td></tr>
{% endif %}
</tbody>
</table>
</div>
<h2 class="section-title" style="margin:2rem 0 0.5rem;">Last cleanup</h2>
{% if not cleanup %}
<p class="tone-dim">None has finished since this version started: the cleanup runs each hour.</p>
{% else %}
<p style="margin:0 0 1rem;">Ran {{ cleanup.at|ago }} and took {{ cleanup.secs|duration }}.
{%- if not cleanup.removed %} Nothing was past its window ({{ cleanup.passes }} passes).{% endif %}</p>
{% if cleanup.removed %}
<div class="card-flush">
<table class="table">
<thead><tr><th>What went</th><th class="num">Rows</th></tr></thead>
<tbody>
{% for what, n in cleanup.removed %}
<tr><td class="cell-name"><span title="{{ what }}">{{ what }}</span></td>
<td class="num nowrap">{{ "{:,}".format(n) }}</td></tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
{% endif %}
<p class="field-hint" style="margin-top:0.75rem;">
How long each kind of data is kept is set under
<a href="/settings/general/">General</a> (data and audit log) and
<a href="/settings/thresholds/">Thresholds &amp; retention</a> (metrics, Docker and logs).</p>
{% endblock %}