textrawl
byJeff Green

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

ParameterTypeRequiredDefaultDescription
countnumberOPTIONAL5Number of past reports to load (1-50)
diffbooleanOPTIONALtrueCompare latest two reports and show changes

Example Request

Default (Last 5 Reports with Diff)

{}

Last 20 Reports Without Diff

{
  "count": 20,
  "diff": false
}

Compare Recent Reports

{
  "count": 2,
  "diff": true
}

Response

{
  "total": 5,
  "reports": [
    {
      "timestamp": "2026-03-26T09:00:00.000Z",
      "databaseSize": "256 MB",
      "tables": 12,
      "critical": 0,
      "warnings": 2
    },
    {
      "timestamp": "2026-03-19T09:00:00.000Z",
      "databaseSize": "248 MB",
      "tables": 12,
      "critical": 1,
      "warnings": 3
    }
  ],
  "diff": {
    "tableChanges": [
      {
        "table": "document_chunks",
        "rowDelta": 500,
        "deadTupleDelta": -200,
        "sizeChange": "+8 MB"
      }
    ],
    "newRecommendations": [],
    "resolvedRecommendations": ["Table needs immediate vacuum"],
    "connectionDelta": -2
  }
}

When diff is false or only one report exists, the diff field is null.

Error Responses

ErrorCauseFix
No saved reportsNo reports in PG_REPORT_DIRRun pg_analyze with save: true first
Report history failedFile read errorCheck 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 from PG_REPORT_DIR (default ./reports/pg-analysis). Reports are created by running pg_analyze with save: true (which does require DATABASE_URL).
  • When diff is true, 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

On this page