fix(trigger): add size threshold to table bloat trigger#34
Merged
randoneering merged 5 commits intoJul 23, 2026
Merged
Conversation
Small tables that are frequently rewritten can trivially have > 50 % table bloat even though the absolute size of the bloat is just a few kB. This is the normal, stable, desirable condition for such tables. In those cases, the suggested VACUUM FULL is an incorrect response. The common solution to this is to add a size threshold to the table bloat trigger. There's no strict guidance for such a threshold, and different sources use different thresholds: - pgexperts/pgx_scripts needs 10 MB of table bloat to trigger by default - keithf4/pg_bloat_check lists example triggers of 10 MB and 1 GB - Heroku's documentation suggests a threshold of 100 MB This commit is written with a conservative threshold to catch obvious false alarms without deviating too far from the function's earlier behaviour.
kqr
commented
Jul 22, 2026
Owner
…practical-table-bloat-trigger
Owner
|
@kqr thank you for the contribution. Edits look good, just don't mind me trying to fix CI 😎. I'll get it resolved and will approve both PRs and merge. Thank you for helping out! |
randoneering
approved these changes
Jul 23, 2026
randoneering
left a comment
Owner
There was a problem hiding this comment.
Looks good-thank you for the added measure in the bloat check and formatting!
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.
Small tables that are frequently rewritten can trivially have > 50 % table bloat even though the absolute size of the bloat is just a few kB. This is the normal, stable, desirable condition for such tables. In those cases, the suggested VACUUM FULL is an incorrect response.
The common solution to this is to add a size threshold to the table bloat trigger. There's no strict guidance for such a threshold, and different sources use different thresholds:
This commit is written with a conservative threshold to catch obvious false alarms without deviating too far from the function's earlier behaviour.
Type of Change
Related Issues
n/a
Testing
PostgreSQL Version Compatibility
Has this code been tested against the following PostgreSQL versions?
Testing notes:
Very small change and little scope for what could go wrong. It seems to work as expected.
Managed Database Platforms
Has this code been deployed and tested on the following platforms?
Platform-specific notes:
Unfortunately not been able to do any testing on managed platforms.
Additional Notes
Confidence Score: 5/5
This looks safe to merge.
No blocking issues found in the changed code. All three SQL variants apply the same threshold, and the predicate compares calculated bloat bytes against a valid PostgreSQL byte-size value.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(trigger): add size threshold to tabl..." | Re-trigger Greptile