pg_report_history
View past Postgres analysis reports and compare trends
View past Postgres analysis reports and compare trends. Shows changes in table sizes, dead tuples, recommendations gained/resolved. Use this to track database health over time.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
count | number | OPTIONAL | 5 | Number of past reports to load (1-50) |
diff | boolean | OPTIONAL | true | Compare latest two reports and show changes |
Example Request
Default (Last 5 Reports with Diff)
Last 20 Reports Without Diff
Compare Recent Reports
Response
When diff is false or only one report exists, the diff field is null.
Error Responses
| Error | Cause | Fix |
|---|---|---|
No saved reports | No reports in PG_REPORT_DIR | Run pg_analyze with save: true first |
Report history failed | File read error | Check PG_REPORT_DIR permissions and path |
Notes
- This tool is read-only and not destructive — it only reads saved report files.
- This tool does not require
DATABASE_URL. It reads previously saved report files fromPG_REPORT_DIR(default./reports/pg-analysis). Reports are created by runningpg_analyzewithsave: true(which does requireDATABASE_URL). - When
diffistrue, the comparison highlights:- Table size changes: growth or shrinkage since the previous report
- Dead tuple changes: increases or decreases in dead tuples
- Recommendations gained: new issues detected since the last report
- Recommendations resolved: issues that are no longer present
Related Tools
pg_analyze- Run a new analysis (usesave: trueto add to history)pg_recommendations- Get current optimization recommendations