PostgresqlBloatTableHigh(>80%) #
The table {{ $labels.relname }} is bloated. You should execute VACUUM {{ $labels.relname }};
Alert Rule
alert: PostgresqlBloatTableHigh(>80%)
annotations:
description: |-
The table {{ $labels.relname }} is bloated. You should execute `VACUUM {{ $labels.relname }};`
VALUE = {{ $value }}
LABELS = {{ $labels }}
runbook: https://srerun.github.io/prometheus-alerts/runbooks/postgres-exporter/postgresqlbloattablehigh(>80%)/
summary: Postgresql bloat table high (> 80%) (instance {{ $labels.instance }})
expr: pg_bloat_table_bloat_pct > 80 and on (relname) (pg_bloat_table_real_size > 200000000)
for: 1h
labels:
severity: warning
Here is a runbook for the Prometheus alert rule:
Meaning #
This alert rule is triggered when a PostgreSQL table is experiencing high bloat, meaning that the table has grown excessively large and is no longer optimal for querying. This can cause performance issues and slow down queries.
Impact #
- Slow query performance
- Increased disk usage
- Potential crashes or timeouts
- Decreased overall system performance
Diagnosis #
To diagnose the issue, follow these steps:
- Identify the affected table: Check the
relname
label in the alert to determine which table is experiencing bloat. - Check table size: Use the
pg_bloat_table_real_size
metric to see how large the table has grown. - Run
VACUUM
command: Execute theVACUUM
command on the affected table to remove any dead tuples and reclaim space. - Investigate query patterns: Review query logs to identify if there are any inefficient queries that may be contributing to the bloat.
Mitigation #
To mitigate the issue, follow these steps:
- Run
VACUUM
command: Execute theVACUUM
command on the affected table to remove any dead tuples and reclaim space. - Reindex the table: Run the
REINDEX
command on the affected table to rebuild the index and improve query performance. - Optimize queries: Review and optimize any inefficient queries that may be contributing to the bloat.
- Schedule regular maintenance: Set up regular maintenance tasks to run
VACUUM
andREINDEX
commands to prevent bloat from occurring in the future.
Remember to monitor the table’s size and performance after taking these mitigation steps to ensure the issue is resolved.