> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tembo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Postgres

> Performance monitoring, slow query detection, and optimization.

<Frame>
  <img src="https://mintcdn.com/test-8862363a/ZNDzs01gTiL6UMVz/images/integrations/postgres.png?fit=max&auto=format&n=ZNDzs01gTiL6UMVz&q=85&s=38e81c4b1e8e95d617ddcbd534f7f831" alt="Postgres" width="2562" height="1441" data-path="images/integrations/postgres.png" />
</Frame>

## Features

* Monitor slow queries and suggest optimizations
* Detect missing and unused indexes
* Open PRs with migration scripts
* MCP server for read-only database access during sessions

## Installation

<Steps>
  <Step title="Add your connection string">
    Go to [Integrations](https://app.tembo.io/integrations) and click **Connect** next to Postgres, then enter your database connection string.
  </Step>
</Steps>

## Usage

After connecting, Tembo can use Postgres tools to run queries against your database during sessions.

Tembo also monitors your database using `pg_stat_statements`. When it finds slow queries or missing indexes, it opens a PR with migration scripts and expected improvement metrics.

Requires `pg_stat_statements` extension: `CREATE EXTENSION IF NOT EXISTS pg_stat_statements;`

## Advanced

<AccordionGroup>
  <Accordion title="MCP server">
    The Postgres MCP can access your database during sessions when querying would help complete the work.
  </Accordion>

  <Accordion title="Best practices">
    You only need to provide a valid connection string. Always review migration PRs before merging, especially for large tables.
  </Accordion>
</AccordionGroup>
