Conversation
Pull Request Test Coverage Report for Build 22101850630Details
💛 - Coveralls |
0xgouda
commented
Feb 17, 2026
Comment on lines
+4194
to
+4195
| Based on the bloat estimation queries from https://github.com/ioguix/pgsql-bloat-estimation. | ||
| **Note - The query filters to bloated indexes over 1 MiB; for large databases, you might only care about indexes over 100 MiB or so** |
Collaborator
Author
There was a problem hiding this comment.
I already cited the query source (I modified it a little) in the metric description, but I am not sure if any additional thing is required by their BSD-2 license
Based on the bloat estimation queries from https://github.com/ioguix/pgsql-bloat-estimation
c878d1a to
c91c75f
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds a new btree_bloat metric to pgwatch for monitoring B-tree index bloat in PostgreSQL databases. The metric estimates index bloat by comparing actual index sizes against expected sizes derived from pg_stats and pg_class catalog metadata. The implementation includes:
Changes:
- Added
btree_bloatmetric definition with bloat estimation query from https://github.com/ioguix/pgsql-bloat-estimation - Added the metric to 8 relevant presets (aiven, azure, exhaustive, full, gce, rds, exhaustive_no_python, debug) with interval 7200 seconds (30 seconds for debug)
- Added visualization panels to both PostgreSQL and Prometheus Grafana dashboards showing top indexes by bloat percentage and size
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
| internal/metrics/metrics.yaml | Added btree_bloat metric definition with SQL query and added to all relevant presets |
| grafana/postgres/v12/index-overview.json | Added new panel showing top indexes by estimated bloat %, minor column reordering in existing panel |
| grafana/prometheus/v12/index-overview-prometheus.json | Added two new panels showing top 10 indexes by bloat % and bloat size |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
btree_bloatmetric to presets with interval7200Top $n indexes by estimated bloat %to panel pg index overview dashboardTop $n indexes by estimated bloat %to panel prom index overview dashboardTop $n indexes by estimated bloat sizeto panel pg index overview dashboardpg dashboard:

prom dashboard:

Closes: #1166