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
Installation
1
Create User
Create a dedicated database user for Tembo with read permissions and
monitoring access. 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 will:- Create a Pull Request - Opens a PR with database migration scripts (e.g.,
CREATE INDEXstatements) - Add Context - Includes detailed explanations of the performance issue and expected improvement
- Provide Metrics - Shows query execution times and estimated performance gains
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.