Features
- Monitor slow queries - Identifies queries that exceed performance thresholds and suggests optimizations
- Detect missing indexes - Analyzes query patterns to find opportunities for new indexes that would improve performance
- Detect unused indexes - Identifies indexes that are no longer being used, helping reduce storage overhead and write performance impact
- Automatic optimization PRs - Generates pull requests with database migration scripts to implement recommended improvements
- Task-based data access - Postgres MCP enables Tembo to query your database when needed for specific tasks (always read-only)
Installation
1
Create User (Optional)
Optional: Create a dedicated database user for Tembo to ensure read-only access.
While not strictly necessary, this is recommended for additional security assurance.
The user needs access to PostgreSQL system catalogs and statistics views.Example SQL:
2
Connect
Navigate to the Integrations page in
Tembo and click the
Connect button next to Postgres. Enter your connection
string in the format: postgresql://username:password@host:5432/database3
Test Connection
Test the connection to verify Tembo can access your database. Once verified,
monitoring begins immediately.
4
Map Repository
Map your database connection to the GitHub, GitLab, or Bitbucket repository where your database migrations are stored. This allows Tembo to create PRs with optimization suggestions.
Usage
Automated Monitoring
Once connected, Tembo continuously monitors your database performance:- Query Performance Analysis - Tracks slow queries using PostgreSQL’s
pg_stat_statementsextension - Index Analysis - Examines query execution plans to identify missing or unused indexes
- Performance Trends - Monitors query performance over time to detect degradation
Pull Requests for Optimizations
When Tembo identifies optimization opportunities, it creates a PR with migration scripts (e.g.,CREATE INDEX), explains the performance issue, and shows expected improvement metrics.
Postgres MCP Integration
Tembo’s Postgres MCP may access your database during task execution when querying it would help complete a task. It runs in restricted mode (read-only), uses your configured connection, and notifies you when accessed.Best Practices
- Use Read-Only Access - Tembo only needs read access to monitor performance; it never modifies your database directly
- Monitor Production Databases - Connect production databases for the most accurate performance insights
- Review Migration Scripts - Always review Tembo’s suggested migrations before merging, especially for large tables
- Test in Staging - Apply migrations to a staging environment first to verify performance improvements
- Enable pg_stat_statements - Ensure the
pg_stat_statementsextension is enabled for comprehensive query analysis. Enable it by runningCREATE EXTENSION IF NOT EXISTS pg_stat_statements;in your database. If the extension isn’t available, addpg_stat_statementstoshared_preload_librariesin yourpostgresql.confand restart PostgreSQL.