Skip to content

Add investigation report on TOAST bloat visibility gap - #6

Closed
shinyaaa wants to merge 2 commits into
masterfrom
claude/toast-bloat-visibility-investigation-cru5vc
Closed

Add investigation report on TOAST bloat visibility gap#6
shinyaaa wants to merge 2 commits into
masterfrom
claude/toast-bloat-visibility-investigation-cru5vc

Conversation

@shinyaaa

Copy link
Copy Markdown
Owner

Investigate whether PostgreSQL core lacks a way to monitor TOAST table
bloat from the parent table's perspective, as groundwork for a future
pgsql-hackers proposal.

Findings:

  • All premises verified against source and a running build of HEAD:
    pg_stat_all_tables does include TOAST rows, but pg_stat_user_tables
    excludes them by definition, and autovacuum processes TOAST tables
    independently of their parents.
  • The accident scenario reproduces: after a parent-only vacuum the
    parent shows n_dead_tup = 0 while its TOAST table holds 52,000 dead
    chunks and 108MB on disk, invisible in pg_stat_user_tables.
  • Survey of 9 monitoring tool lineages shows only Datadog links TOAST
    dead tuples to the parent table; the mainstream bloat query family
    (check_postgres / wiki) is structurally blind to TOAST.
  • Prior art: pg_stat_toast (2022) was withdrawn over new-counter
    overhead, which does not apply here since the recommended minimal
    patch is a SQL-only view change reusing existing per-relation stats,
    mirroring the pg_statio_all_tables toast_blks_* precedent.

The report recommends proposing toast_relid plus a small set of
toast_-prefixed columns in pg_stat_all_tables, with pointers to all
evidence (file:line, commit hashes, thread URLs).

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01XfVEBxd7m1SHxv2aqREW2u

claude added 2 commits July 31, 2026 02:05
Investigate whether PostgreSQL core lacks a way to monitor TOAST table
bloat from the parent table's perspective, as groundwork for a future
pgsql-hackers proposal.

Findings:
- All premises verified against source and a running build of HEAD:
  pg_stat_all_tables does include TOAST rows, but pg_stat_user_tables
  excludes them by definition, and autovacuum processes TOAST tables
  independently of their parents.
- The accident scenario reproduces: after a parent-only vacuum the
  parent shows n_dead_tup = 0 while its TOAST table holds 52,000 dead
  chunks and 108MB on disk, invisible in pg_stat_user_tables.
- Survey of 9 monitoring tool lineages shows only Datadog links TOAST
  dead tuples to the parent table; the mainstream bloat query family
  (check_postgres / wiki) is structurally blind to TOAST.
- Prior art: pg_stat_toast (2022) was withdrawn over new-counter
  overhead, which does not apply here since the recommended minimal
  patch is a SQL-only view change reusing existing per-relation stats,
  mirroring the pg_statio_all_tables toast_blks_* precedent.

The report recommends proposing toast_relid plus a small set of
toast_-prefixed columns in pg_stat_all_tables, with pointers to all
evidence (file:line, commit hashes, thread URLs).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfVEBxd7m1SHxv2aqREW2u
The investigation report and its verification script are tracked; the
in-tree build logs, the throwaway install tree, and the test cluster
are not.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XfVEBxd7m1SHxv2aqREW2u
@shinyaaa shinyaaa closed this Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants