PostgreSQL
Connect your PostgreSQL databases to enable Tony (Database Engineer) to analyze queries, optimize performance, and monitor database health.Supported Platforms
| Platform | Support |
|---|---|
| Self-hosted PostgreSQL | 12.x, 13.x, 14.x, 15.x, 16.x |
| AWS RDS PostgreSQL | All versions |
| AWS Aurora PostgreSQL | All versions |
| Google Cloud SQL | All PostgreSQL versions |
| Azure Database for PostgreSQL | Flexible Server, Single Server |
Setup
1
Connect as Admin
Connect to your PostgreSQL instance using an admin account:
2
Create Read-Only User
Create a dedicated user for CloudThinker:
3
Grant Connection
Allow connection to the database:
4
Grant Schema Usage
Grant usage on schemas:
5
Grant Select Permissions
Grant SELECT on all tables and views:
6
Enable pg_stat_statements
This extension is required for query analysis:For RDS/Aurora, add to parameter group:
7
Configure Network Access
Ensure CloudThinker can reach your database:
- Add CloudThinker IPs to security group / firewall
- For RDS: Enable public access or use VPC peering
8
Add Connection in CloudThinker
Navigate to Connections → PostgreSQL and enter:
- Host
- Port (default: 5432)
- Database name
- Username:
cloudthinker_readonly - Password
- SSL mode (recommended: require)
Connection String Format
Required Permissions
Minimum
Recommended (Full Analysis)
Agent Capabilities
Once connected, Tony can:| Capability | Description |
|---|---|
| Query Analysis | Identify slow queries, analyze execution plans |
| Index Recommendations | Find missing indexes, identify unused indexes |
| Performance Metrics | Monitor connections, I/O, cache hit rates |
| Table Statistics | Analyze table bloat, dead tuples, vacuum status |
| Replication Monitoring | Check lag, streaming status (if replica) |
Example Prompts
Connection Options
| Option | Description | Default |
|---|---|---|
| SSL Mode | disable, allow, prefer, require, verify-ca, verify-full | require |
| Connection Timeout | Seconds to wait for connection | 10 |
| Statement Timeout | Max query execution time (ms) | 30000 |
Troubleshooting
Connection refused
Connection refused
- Verify host and port are correct
- Check security group / firewall allows CloudThinker IPs
- For RDS: Ensure “Publicly accessible” is enabled or use VPC peering
- Confirm PostgreSQL is listening on the correct interface
Authentication failed
Authentication failed
- Verify username and password are correct
- Check
pg_hba.confallows the connection method - Ensure user has CONNECT privilege on the database
Missing pg_stat_statements
Missing pg_stat_statements
- Verify extension is installed:
SELECT * FROM pg_extension WHERE extname = 'pg_stat_statements'; - Check
shared_preload_librariesincludespg_stat_statements - Restart PostgreSQL after changing
shared_preload_libraries - For RDS: Modify parameter group and reboot
Permission denied
Permission denied
- Verify user has SELECT on required tables
- Grant
pg_read_all_statsrole for PostgreSQL 14+ - Check schema permissions with
\dn+in psql
Security Best Practices
- Strong passwords - Use complex, unique passwords
- SSL encryption - Always use SSL mode
requireor higher - Network restrictions - Limit access to CloudThinker IPs only
- Minimal permissions - Grant only SELECT, never write access
- Credential rotation - Rotate passwords every 90 days