Error Triage Hub (9)
PostgreSQL notifications Table & Index Bloat Slowing Inboxes
Chatwoot appends rows to notifications and reporting_events for every message event; unpruned tables grow past 20-60 GB and thrash PostgreSQL shared_buffers.
Bloat: > 15M rows in notifications | Latency: > 1,200 ms queries
Why Unpruned Notification Tables Starve Active Queries
High-volume support teams generate millions of agent notification records and read receipts every quarter. Once notifications plus its GIN/B-tree indexes exceed PostgreSQL shared_buffers and host page cache, every inbox load triggers random NVMe reads.
Measuring Dead Tuples and Table Size in psql
Query pg_total_relation_size('notifications') and pg_stat_user_tables for n_dead_tup. If dead tuples exceed 20% or total table size dwarfs conversations, autovacuum is lagging behind write velocity and old notifications need scheduled pruning.
Measured Thresholds & Configuration
| PostgreSQL Metric | Healthy Chatwoot DB | Bloated Stall State |
|---|---|---|
| notifications table + index | < 2 GB (90-day retention) | 18 - 65 GB unpruned |
| Index cache hit ratio | > 99.0% | < 88.0% (disk thrashing) |
| Inbox query p95 | < 45 ms | 900 - 3,400 ms |