textrawl
byJeff Green

pg_recommendations

Get actionable optimization recommendations for Postgres

Get actionable optimization recommendations for Postgres. Runs analysis and returns only the categorized recommendations with severity, descriptions, and suggested fixes.

Parameters

ParameterTypeRequiredDefaultDescription
severityenumOPTIONALallFilter recommendations by minimum severity: all, critical, warning, info

Example Request

All Recommendations

{}

Critical Only

{
  "severity": "critical"
}

Warnings and Above

{
  "severity": "warning"
}

Response

{
  "total": 4,
  "recommendations": [
    {
      "severity": "critical",
      "category": "vacuum",
      "title": "Table needs immediate vacuum",
      "description": "Table document_chunks has 50000 dead tuples (25% dead tuple ratio), significantly impacting query performance.",
      "suggestion": "VACUUM ANALYZE public.document_chunks;",
      "reference": "https://www.postgresql.org/docs/current/routine-vacuuming.html"
    },
    {
      "severity": "warning",
      "category": "index",
      "title": "Unused index detected",
      "description": "Index idx_old_search on document_chunks has 0 scans since last stats reset.",
      "suggestion": "DROP INDEX idx_old_search;"
    },
    {
      "severity": "info",
      "category": "configuration",
      "title": "Consider enabling pg_stat_statements",
      "description": "pg_stat_statements extension is not enabled. Query performance tracking is unavailable.",
      "suggestion": "CREATE EXTENSION IF NOT EXISTS pg_stat_statements;",
      "reference": "https://www.postgresql.org/docs/current/pgstatstatements.html"
    }
  ]
}

Recommendation Fields

Each recommendation includes:

FieldTypeDescription
severityenumcritical, warning, or info
categorystringClassification (e.g. vacuum, index, configuration, bloat)
titlestringBrief summary of the issue
descriptionstringWhat the issue is and why it matters
suggestionstringReady-to-run SQL or actionable fix
referencestring (optional)Link to relevant documentation

Error Responses

ErrorCauseFix
DATABASE_URL not configuredMissing Postgres connection stringSet DATABASE_URL environment variable
Recommendations failedDatabase connection or query errorVerify DATABASE_URL and database connectivity

Notes

  • This tool is read-only and not destructive — it does not modify your database.
  • Requires the DATABASE_URL environment variable to be set (direct pg connection, independent of Supabase).
  • Use severity filtering to focus on the most impactful issues first.
  • For the full analysis report (table stats, index health, etc.), use pg_analyze instead.

On this page