A PostgreSQL assistant for developers Understand, optimize, and improve your PostgreSQL database with ease.
See the code
A continuous PostgreSQL improvement platform.
Analyze PostgreSQL, turn findings into an actionable remediation plan, track what changed, and measure whether the workload actually improved.
Designed for one database or a fleet of thousands.
⭐ Star pgAssistant on GitHub if it helps you improve your PostgreSQL databases.
pgAssistant is an open-source platform that turns PostgreSQL evidence into prioritized action. It combines database introspection, workload analysis, specialized advisors, implementation planning, historical evidence, and result measurement in a single web interface.
pgAssistant Collector extends this loop with historical workload and environment measurements, connecting recommendations to observed outcomes. Together, they help teams answer four recurring questions:
AI assistance is optional. The core advisors remain deterministic and can be used without an LLM.
The Executive Plan transforms technical findings into an ordered remediation plan with priorities, ownership, dependencies, and implementation guidance.

pgAssistant is not a real-time monitoring system. It builds a continuous improvement loop from periodic database and workload collections; monitoring platforms remain the source for what is happening right now.
Observe → Diagnose → Prioritize → Plan → Implement → Collect again → Measure
↑ │
└────────────────────────── Repeat continuously ────────────────────┘
pgAssistant supports the full loop:
The product components feed the same loop rather than producing disconnected reports:
PostgreSQL evidence
│
┌─────────────────┼─────────────────┐
│ │ │
Global Advisor Index Advisor Parameter & maintenance
│ │ │
└─────────────────┼─────────────────┘
↓
Executive Plan
↓
Implementation
↓
Workload Insights
↓
New evidence


The Executive Plan groups related findings into ordered, team-owned work packages. It makes dependencies and responsibilities explicit, so teams can move from diagnosis to execution instead of working through an unstructured list of recommendations.
P1 — DEV
Rewrite query Q42
Add the missing FK index on orders(customer_id)
P2 — OPS
Tune autovacuum for the affected high-churn tables
Review the workload-related PostgreSQL settings
P3 — DEV/OPS
Drop unsed index, Review index opportunity on public.orders
pgAssistant supports two complementary operating modes:
| Mode | What it provides |
|---|---|
| One database | Deep-dive SQL, schema, configuration, and maintenance analysis with a concrete remediation plan for developers and DBAs. |
| PostgreSQL fleet | Standardized collection, centralized prioritization, historical comparison, and trend analysis across hundreds or thousands of databases. |
For a large PostgreSQL estate, two companion projects automate and centralize the same analyses:
| Project | Role |
|---|---|
| pgAssistant Collector | Runs selected pgAssistant jobs across declared databases and stores historical snapshots in a central PostgreSQL repository. |
| pgAssistant Grafana | Displays fleet-wide priorities and trends, including the databases requiring attention, ranked queries, advisor findings, and recommendation evolution. |
Together, the three projects let teams:
PostgreSQL fleet → Collector → Repository → pgAssistant → Executive Plan
↑ ↓ ↓ ↓
└──────────── Collect again ← Measure results ← Implement changes
↓
Grafana fleet overview
Try the database analysis interface at https://ov-004f8b.infomaniak.ch/.
postgresql://postgres:demo@demo-db:5432/northwind
Explore the fleet dashboards in the Grafana demo. The demo credentials are documented in the pgAssistant Grafana repository.
The demo database is reset daily. AI features are disabled: do not enter personal API keys.
The Global, Index, Parameter, Autovacuum, and Fillfactor advisors produce reproducible recommendations. The Executive Plan consolidates related findings by objective or affected object into ordered work packages instead of a disconnected list of checks and SQL commands.
The currently available advisors cover:
ORDER BY, including ORDER BY ... LIMIT; indexes supporting GROUP BY; existing equivalent-index detection; and row-estimation or statistics observations that make an automatic recommendation unsafe.work_mem, effective_cache_size, random_page_cost, effective_io_concurrency, max_parallel_workers_per_gather, and max_wal_size based on workload and generic-plan signals.ANALYZE, VACUUM, and table-specific autovacuum tuning for never-analyzed, stale-analysis, never-vacuumed, stale-vacuum, modified-row, and dead-tuple pressure conditions.autovacuum, autovacuum_max_workers, autovacuum_naptime, vacuum and analyze scale factors and thresholds, autovacuum_vacuum_cost_delay, autovacuum_vacuum_cost_limit, and log_autovacuum_min_duration.pgAssistant can analyze an individual SQL statement or the workload collected by pg_stat_statements:
EXPLAIN ANALYZE;[!CAUTION]
EXPLAIN ANALYZEexecutes the statement. Review queries carefully and use a suitable database role, especially outside a development environment.







Use the published Docker image and expose the application on port 8080:
docker run --name pgassistant --rm -p 8080:5005 bertrand73/pgassistant:latest
Then open http://localhost:8080.
For persistent settings, LLM configuration, Docker Compose, and database connectivity examples, see the Docker installation guide.
For a local source installation, see the Python installation guide.
pgAssistant provides a versioned API for integrating its analysis and planning
capabilities with automation platforms, database portals, CI/CD workflows, and
other operational tools. These endpoints do not depend on a browser session and
do not change the historical /api/v1 routes.
| Endpoint | Purpose |
|---|---|
POST /api/v2/pgtune | Generate a PostgreSQL configuration baseline from explicit resources or an optional database connection. |
POST /api/v2/executive-plan | Run the advisors and return a prioritized, integration-friendly Executive Plan. |
POST /api/v2/executive-plan/report.pdf | Download the Workload Insight PDF for DEV, OPS, or both, optionally including AI DB Design analysis. |
Authentication is optional and controlled by PGA_API_TOKEN. When configured,
clients must send Authorization: Bearer <token>; when it is unset or empty,
authentication is disabled.
/api/v2/docs/api/v2/swagger.jsonpgAssistant accepts standard libpq-compatible PostgreSQL connection URIs, including additional connection options:
postgresql://user:password@host:5432/database
For the best workload analysis, enable pg_stat_statements. Some features degrade gracefully when the extension is unavailable, and generic-plan advisors require PostgreSQL 16 or newer.
Use a dedicated database account with only the permissions required for the analyses you intend to run. Multi-database mode also requires the account to be able to connect to each selected database.
PostgreSQL release metadata is cached for 30 days in postgresql_versions_cache.json. The Docker image stores it in /home/pgassistant/data/postgresql_versions_cache.json. Set PGA_POSTGRESQL_VERSIONS_CACHE_FILE to use another location or mount /home/pgassistant/data to preserve the cache when containers are replaced.
Set the optional COLLECTOR_URI environment variable to connect pgAssistant to
a pgAssistant Collector repository:
COLLECTOR_URI=postgresql://collector_reader:password@collector-host:5432/pga_collector
When configured, the Database connection page displays a Collector tab where the user searches for and selects the target associated with the active database. The selection is stored in the session and shared by Executive Plan history, Query activity history, and Workload Insights. The Executive Plan History tab provides 7, 15, 30-day and complete-history comparisons, DEV/OPS team filters, and work-package-grouped changes. The latest collector snapshot is also compared with a freshly generated Executive Plan, so a correction appears immediately; the next complete collection confirms it. Partial live plans never confirm a correction.
Workload Insights compares consecutive periodic measurements—not a real-time monitoring stream. It correlates recommendation changes with execution time, call volume, query type, PostgreSQL version and settings changes, and the queries with the largest workload impact. This provides evidence about what changed after a decision while preserving the distinction between correlation, a no-longer-detected finding, and a confirmed deployment.
The collector connection is opened in read-only mode. A dedicated read-only PostgreSQL role is recommended.
| Role | What pgAssistant helps with |
|---|---|
| Developer | SQL performance, index opportunities, schema design, and actionable implementation guidance. |
| DBA | Reproducible diagnostics, configuration, maintenance, autovacuum, and database health. |
| SRE / Operations | Workload evolution, operational risks, environment changes, and fleet priorities. |
| Platform team | Standardized PostgreSQL analysis and remediation tracking across hundreds or thousands of databases. |
| Engineering manager / Tech lead | Prioritized plans, clear DEV/OPS ownership, remediation progress, and measurable results. |
| Team without dedicated PostgreSQL expertise | A shareable implementation plan instead of an unexplained list of findings. |
pgAssistant is released under the MIT License.
201 followers · starred Sep 2025
416 followers · starred Jan 2026
A PostgreSQL assistant for developers Understand, optimize, and improve your PostgreSQL database with ease.
See the code
A continuous PostgreSQL improvement platform.
Analyze PostgreSQL, turn findings into an actionable remediation plan, track what changed, and measure whether the workload actually improved.
Designed for one database or a fleet of thousands.
⭐ Star pgAssistant on GitHub if it helps you improve your PostgreSQL databases.
pgAssistant is an open-source platform that turns PostgreSQL evidence into prioritized action. It combines database introspection, workload analysis, specialized advisors, implementation planning, historical evidence, and result measurement in a single web interface.
pgAssistant Collector extends this loop with historical workload and environment measurements, connecting recommendations to observed outcomes. Together, they help teams answer four recurring questions:
AI assistance is optional. The core advisors remain deterministic and can be used without an LLM.
The Executive Plan transforms technical findings into an ordered remediation plan with priorities, ownership, dependencies, and implementation guidance.

pgAssistant is not a real-time monitoring system. It builds a continuous improvement loop from periodic database and workload collections; monitoring platforms remain the source for what is happening right now.
Observe → Diagnose → Prioritize → Plan → Implement → Collect again → Measure
↑ │
└────────────────────────── Repeat continuously ────────────────────┘
pgAssistant supports the full loop:
The product components feed the same loop rather than producing disconnected reports:
PostgreSQL evidence
│
┌─────────────────┼─────────────────┐
│ │ │
Global Advisor Index Advisor Parameter & maintenance
│ │ │
└─────────────────┼─────────────────┘
↓
Executive Plan
↓
Implementation
↓
Workload Insights
↓
New evidence


The Executive Plan groups related findings into ordered, team-owned work packages. It makes dependencies and responsibilities explicit, so teams can move from diagnosis to execution instead of working through an unstructured list of recommendations.
P1 — DEV
Rewrite query Q42
Add the missing FK index on orders(customer_id)
P2 — OPS
Tune autovacuum for the affected high-churn tables
Review the workload-related PostgreSQL settings
P3 — DEV/OPS
Drop unsed index, Review index opportunity on public.orders
pgAssistant supports two complementary operating modes:
| Mode | What it provides |
|---|---|
| One database | Deep-dive SQL, schema, configuration, and maintenance analysis with a concrete remediation plan for developers and DBAs. |
| PostgreSQL fleet | Standardized collection, centralized prioritization, historical comparison, and trend analysis across hundreds or thousands of databases. |
For a large PostgreSQL estate, two companion projects automate and centralize the same analyses:
| Project | Role |
|---|---|
| pgAssistant Collector | Runs selected pgAssistant jobs across declared databases and stores historical snapshots in a central PostgreSQL repository. |
| pgAssistant Grafana | Displays fleet-wide priorities and trends, including the databases requiring attention, ranked queries, advisor findings, and recommendation evolution. |
Together, the three projects let teams:
PostgreSQL fleet → Collector → Repository → pgAssistant → Executive Plan
↑ ↓ ↓ ↓
└──────────── Collect again ← Measure results ← Implement changes
↓
Grafana fleet overview
Try the database analysis interface at https://ov-004f8b.infomaniak.ch/.
postgresql://postgres:demo@demo-db:5432/northwind
Explore the fleet dashboards in the Grafana demo. The demo credentials are documented in the pgAssistant Grafana repository.
The demo database is reset daily. AI features are disabled: do not enter personal API keys.
The Global, Index, Parameter, Autovacuum, and Fillfactor advisors produce reproducible recommendations. The Executive Plan consolidates related findings by objective or affected object into ordered work packages instead of a disconnected list of checks and SQL commands.
The currently available advisors cover:
ORDER BY, including ORDER BY ... LIMIT; indexes supporting GROUP BY; existing equivalent-index detection; and row-estimation or statistics observations that make an automatic recommendation unsafe.work_mem, effective_cache_size, random_page_cost, effective_io_concurrency, max_parallel_workers_per_gather, and max_wal_size based on workload and generic-plan signals.ANALYZE, VACUUM, and table-specific autovacuum tuning for never-analyzed, stale-analysis, never-vacuumed, stale-vacuum, modified-row, and dead-tuple pressure conditions.autovacuum, autovacuum_max_workers, autovacuum_naptime, vacuum and analyze scale factors and thresholds, autovacuum_vacuum_cost_delay, autovacuum_vacuum_cost_limit, and log_autovacuum_min_duration.pgAssistant can analyze an individual SQL statement or the workload collected by pg_stat_statements:
EXPLAIN ANALYZE;[!CAUTION]
EXPLAIN ANALYZEexecutes the statement. Review queries carefully and use a suitable database role, especially outside a development environment.







Use the published Docker image and expose the application on port 8080:
docker run --name pgassistant --rm -p 8080:5005 bertrand73/pgassistant:latest
Then open http://localhost:8080.
For persistent settings, LLM configuration, Docker Compose, and database connectivity examples, see the Docker installation guide.
For a local source installation, see the Python installation guide.
pgAssistant provides a versioned API for integrating its analysis and planning
capabilities with automation platforms, database portals, CI/CD workflows, and
other operational tools. These endpoints do not depend on a browser session and
do not change the historical /api/v1 routes.
| Endpoint | Purpose |
|---|---|
POST /api/v2/pgtune | Generate a PostgreSQL configuration baseline from explicit resources or an optional database connection. |
POST /api/v2/executive-plan | Run the advisors and return a prioritized, integration-friendly Executive Plan. |
POST /api/v2/executive-plan/report.pdf | Download the Workload Insight PDF for DEV, OPS, or both, optionally including AI DB Design analysis. |
Authentication is optional and controlled by PGA_API_TOKEN. When configured,
clients must send Authorization: Bearer <token>; when it is unset or empty,
authentication is disabled.
/api/v2/docs/api/v2/swagger.jsonpgAssistant accepts standard libpq-compatible PostgreSQL connection URIs, including additional connection options:
postgresql://user:password@host:5432/database
For the best workload analysis, enable pg_stat_statements. Some features degrade gracefully when the extension is unavailable, and generic-plan advisors require PostgreSQL 16 or newer.
Use a dedicated database account with only the permissions required for the analyses you intend to run. Multi-database mode also requires the account to be able to connect to each selected database.
PostgreSQL release metadata is cached for 30 days in postgresql_versions_cache.json. The Docker image stores it in /home/pgassistant/data/postgresql_versions_cache.json. Set PGA_POSTGRESQL_VERSIONS_CACHE_FILE to use another location or mount /home/pgassistant/data to preserve the cache when containers are replaced.
Set the optional COLLECTOR_URI environment variable to connect pgAssistant to
a pgAssistant Collector repository:
COLLECTOR_URI=postgresql://collector_reader:password@collector-host:5432/pga_collector
When configured, the Database connection page displays a Collector tab where the user searches for and selects the target associated with the active database. The selection is stored in the session and shared by Executive Plan history, Query activity history, and Workload Insights. The Executive Plan History tab provides 7, 15, 30-day and complete-history comparisons, DEV/OPS team filters, and work-package-grouped changes. The latest collector snapshot is also compared with a freshly generated Executive Plan, so a correction appears immediately; the next complete collection confirms it. Partial live plans never confirm a correction.
Workload Insights compares consecutive periodic measurements—not a real-time monitoring stream. It correlates recommendation changes with execution time, call volume, query type, PostgreSQL version and settings changes, and the queries with the largest workload impact. This provides evidence about what changed after a decision while preserving the distinction between correlation, a no-longer-detected finding, and a confirmed deployment.
The collector connection is opened in read-only mode. A dedicated read-only PostgreSQL role is recommended.
| Role | What pgAssistant helps with |
|---|---|
| Developer | SQL performance, index opportunities, schema design, and actionable implementation guidance. |
| DBA | Reproducible diagnostics, configuration, maintenance, autovacuum, and database health. |
| SRE / Operations | Workload evolution, operational risks, environment changes, and fleet priorities. |
| Platform team | Standardized PostgreSQL analysis and remediation tracking across hundreds or thousands of databases. |
| Engineering manager / Tech lead | Prioritized plans, clear DEV/OPS ownership, remediation progress, and measurable results. |
| Team without dedicated PostgreSQL expertise | A shareable implementation plan instead of an unexplained list of findings. |
pgAssistant is released under the MIT License.
201 followers · starred Sep 2025
416 followers · starred Jan 2026