Skip to main content

PostgreSQL Integration

Connect a PostgreSQL database so Annie can query it read-only and correlate application data, slow queries, and database health with your infrastructure graph.
The PostgreSQL integration is currently in beta. Supported tools and database health checks may expand as we harden the connector.

What Annie can do

  • Discover the schema — list schemas, tables, views, sequences, and extensions, and read columns, constraints, and indexes
  • Run SQL — execute read-only SELECT queries to answer questions about your application data
  • Explain queries — show execution plans with EXPLAIN
  • Find slow queries — rank the slowest or most resource-hungry queries from pg_stat_statements
  • Check database health — indexes, connections, vacuum, sequences, replication, buffer cache, and constraints
  • Recommend indexes — for your overall workload or for specific queries (uses the hypopg extension)

Quickstart

  1. Create a dedicated read-only role for Annie.
  2. Allow Anyshift’s outbound IPs to reach your database.
  3. Go to the Anyshift integrations page.
  4. In the Analytics section, open PostgreSQL and click Add connection.
  5. Fill in the form:
    • Name — a label for this connection, for example Production PostgreSQL
    • Host — the public hostname or IP of your database, for example db.example.com
    • Port — defaults to 5432
    • Database — the database Annie should query
    • Username and Password — the read-only role you created
    • SSL mode — keep the default require (see SSL mode)
  6. Click Save PostgreSQL connection.
On save, Anyshift connects to the database and runs SELECT 1 (10-second timeout). The connection shows Active when it succeeds and Error when it fails. Only active connections are available to Annie.

Multiple connections

You can add as many connections as you need, for example one per database or environment. Annie sees each connection as a separate PostgreSQL server and reports which one it queried.

Security model

Annie’s PostgreSQL access is strictly read-only:
  • Queries run through Annie’s PostgreSQL MCP server in restricted mode: every statement runs in a read-only transaction with a statement timeout. Restricted mode is enforced server-side and cannot be turned off.
  • INSERT, UPDATE, DELETE, and DDL are refused.
  • Your password is encrypted at rest with AWS KMS and is never exposed to the AI agent.
  • Only publicly reachable hosts are accepted. Hosts that resolve to private, loopback, link-local, or other non-public addresses are rejected.
We still recommend a dedicated read-only role, so the database itself enforces the same limits.

Create a read-only role

Run the following as an administrator: creating the role needs CREATEROLE (or superuser), and the grants must come from the owner of the database, schemas, and tables, or from a role allowed to grant on them. Replace the password, database, and schema names with your own, and repeat the schema grants for every schema Annie should read.
Slow-query analysis and workload index recommendations need the pg_stat_statements extension, and index recommendations need hypopg. Annie works without them and tells you when an extension is missing. On managed services, enable them through the provider’s parameter group or extension settings, then run CREATE EXTENSION in the database.

Network access

Your database must be reachable from the internet on its PostgreSQL port. If it sits behind a firewall, security group, or IP allowlist, allow inbound traffic from Anyshift’s outbound IP addresses: See Network Requirements for the downloadable list.

SSL mode

verify-ca and verify-full need a trusted root certificate on the client side. Annie’s query runtime does not ship your provider’s CA bundle, so these modes can fail even when the save-time check succeeds. Use require unless our team has confirmed certificate verification for your provider.

Example questions

  • “Which tables in the orders database grew the most, and do they have the indexes they need?”
  • “What are the slowest queries right now, and why is the top one slow?”
  • “Run a health check on the production database: bloat, unused indexes, vacuum, and connections.”
  • “How many orders failed per hour since yesterday’s deploy?”
  • “Explain this query and suggest an index: SELECT * FROM events WHERE account_id = $1 ORDER BY created_at DESC LIMIT 50”

Troubleshooting

”Invalid PostgreSQL host”

The connection is not saved. The message tells you why:
  • “host resolves to a non-public address” — the host resolves to a private, loopback, link-local, or other internal address. Annie only connects to publicly reachable databases. Use the database’s public endpoint.
  • “could not resolve host” — the hostname does not exist in public DNS. Check the spelling, or use the public IP.

Status Error with a timeout

Anyshift could not reach the database within 10 seconds. Usually a firewall, security group, or network ACL blocks the connection:
  • Allow Anyshift’s outbound IPs on the PostgreSQL port
  • Make sure the database is publicly accessible, for example Publicly accessible on Amazon RDS
  • Check the host and port

Status Error with “password authentication failed”

  • Check the username and password
  • Make sure your pg_hba.conf (or provider settings) allows password logins from Anyshift’s IPs
  • Make sure the role has LOGIN and CONNECT on the database

SSL errors

  • “SSL is not enabled on the server” — the server does not accept TLS. Enable SSL on the server; switch to a weaker mode only if you accept unencrypted traffic.
  • Certificate verification errors — switch from verify-ca / verify-full to require (see SSL mode).

Annie says a table is missing or permission is denied

Grant USAGE on the schema and SELECT on its tables to the role, as in Create a read-only role.

Annie doesn’t use PostgreSQL

  • Verify the connection shows Active on the integrations page
  • Make sure Annie’s access to this connection is not disabled in your integration settings
  • After fixing a connection in Error, update it so Anyshift re-tests it