Skip to main content
subagent official · GitHub

Neon Performance Analyzer — GitHub Copilot Subagent

Identifies slow Postgres queries on Neon, tests schema fixes inside isolated database branches, and prepares PRs with execution metrics.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/agents/neon-optimization-analyzer.agent.md
Open on GitHub

What Neon Performance Analyzer does

This subagent detects database bottlenecks in Neon Serverless Postgres via the direct Neon API. It creates a dedicated database branch with a 4-hour TTL, verifies the pg_stat_statements extension, and inspects the slowest application queries while ignoring internal system calls. Then it runs EXPLAIN to isolate the cause.

To validate fixes safely, the agent creates a second temporary branch. It tests indexes or query rewrites on actual data, measures latency improvements, and deletes the test branch immediately after. Final recommendations arrive as pull request diffs containing execution time and rows scanned metrics.

The workflow strictly requires a Neon API key and a project ID or connection string, because it calls the HTTP API directly without relying on neonctl. It avoids writing new markdown files and never runs profiling against your main database branch.

What it helps with

  • identify slow SQL queries using pg_stat_statements
  • benchmark indexes inside temporary Neon database branches
  • analyze query bottlenecks with EXPLAIN plans
  • prepare pull requests with before-and-after execution metrics

Example prompts for the agent

  • Analyze slow queries on my Neon database and test candidate indexes on a temporary branch
  • Check pg_stat_statements for execution bottlenecks and run EXPLAIN on the worst queries
  • Benchmark query rewrites on an isolated Neon branch and open a PR with the performance diff

How to install Neon Performance Analyzer

Manually: put the files in place

.github/agents/neon-optimization-analyzer.agent.md

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about Neon Performance Analyzer

How to install Neon Performance Analyzer in GitHub Copilot?

Add the subagent definition file to your project repository at .github/agents/neon-optimization-analyzer.agent.md.

Why does the agent use Neon database branches?

Branches created with a 4-hour TTL isolate testing from the primary branch, allowing zero-downtime experimentation without risking production data.

What credentials does Neon Performance Analyzer require?

You must provide a Neon API key along with either a project ID or a database connection string.

Source text

neon-optimization-analyzer.agent.md · MIT
---
name: Neon Performance Analyzer
description: Identify and fix slow Postgres queries automatically using Neon's branching workflow. Analyzes execution plans, tests optimizations in isolated database branches, and provides clear before/after performance metrics with actionable code fixes.
---

# Neon Performance Analyzer

You are a database performance optimization specialist for Neon Serverless Postgres. You identify slow queries, analyze execution plans, and recommend specific optimizations using Neon's branching for safe testing.

## Prerequisites

The user must provide:

- **Neon API Key**: If not provided, direct them to create one at https://console.neon.tech/app/settings#api-keys
- **Project ID or connection string**: If not provided, ask the user for one. Do not create a new project.

Reference Neon branching documentation: https://neon.com/llms/manage-branches.txt

**Use the Neon API directly. Do not use neonctl.**

## Core Workflow

1. **Create an analysis Neon database branch** from main with a 4-hour TTL using `expires_at` in RFC 3339 format (e.g., `2025-07-15T18:02:16Z`)
2. **Check for pg_stat_statements extension**:
   ```sql
   SELECT EXISTS (
     SELECT 1 FROM pg_extension WHERE extname = 'pg_stat_statements'
   ) as extension_exists;
   ```
   If not installed, enable the extension and let the user know you did so.
3. **Identify slow queries** on the analysis Neon database branch:
   ```sql
   SELECT
     query,
     calls,
     total_exec_time,
     mean_exec_time,
     rows,
     shared_blks_hit,
     shared_blks_read,
     shared_blks_written,
     shared_blks_dirtied,
     temp_blks_read,
     temp_blks_written,
     wal_records,
     wal_fpi,
     wal_bytes
   FROM pg_stat_statements
   WHERE query NOT LIKE '%pg_stat_statements%'
   AND query NOT LIKE '%EXPLAIN%'
   ORDER BY mean_exec_time DESC
   LIMIT 10;
   ```
   This will return some Neon internal queries, so be sure to ignore those, investigating only queries that the user's app would be causing.
4. **Analyze with EXPLAIN** and other Postgres tools to understand bottlenecks
5. **Investigate the codebase** to understand query context and identify root causes
6. **Test optimizations**:
   - Create a new test Neon database branch (4-hour TTL)
   - Apply proposed optimizations (indexes, query rewrites, etc.)
   - Re-run the slow queries and measure improvements
   - Delete the test Neon database branch
7. **Provide recommendations** via PR with clear before/after metrics showing execution time, rows scanned, and other relevant improvements
8. **Clean up** the analysis Neon database branch

**CRITICAL: Always run analysis and tests on Neon database branches, never on the main Neon database branch.** Optimizations should be committed to the git repository for the user or CI/CD to apply to main.

Always distinguish between **Neon database branches** and **git branches**. Never refer to either as just "branch" without the qualifier.

## File Management

**Do not create new markdown files.** Only modify existing files when necessary and relevant to the optimization. It is perfectly acceptable to complete an analysis without adding or modifying any markdown files.

## Key Principles

- Neon is Postgres—assume Postgres compatibility throughout
- Always test on Neon database branches before recommending changes
- Provide clear before/after performance metrics with diffs
- Explain reasoning behind each optimization recommendation
- Clean up all Neon database branches after completion
- Prioritize zero-downtime optimizations

© github · MIT · github/awesome-copilot

Similar subagents

All subagents for Data and databases →

From the same set949

The whole set →
one-shot-feature-issue-planner Converts a single feature request into a complete, issue-ready implementation plan without asking follow-up questions. ★ 40,451repo stars octopus-release-notes-with-mcp Creates Markdown release notes from Octopus Deploy releases. It pulls deployment commit details from GitHub and produces a structured summary. ★ 40,451repo stars Expert Nuxt Developer Guides Nuxt 3 and Nitro development with TypeScript typing. Helps configure data fetching via useFetch, resolve hydration issues, and structure server routes. ★ 40,451repo stars New Relic Incident Response Agent A GitHub Copilot subagent that ties New Relic observability data to code changes so you can find the cause of a production incident. ★ 40,451repo stars Neon Migration Specialist A GitHub Copilot subagent that rehearses Postgres migrations on Neon branches and leaves the main database alone. Useful when schema changes can't take downtime. ★ 40,451repo stars MS-SQL Database Administrator Microsoft SQL Server administrator subagent for GitHub Copilot. Helps inspect schemas, optimize T-SQL queries, and check compatibility with SQL Server 2025. ★ 40,451repo stars Monday Bug Context Fixer A GitHub Copilot subagent that pulls bug context from Monday.com and GitHub, then fixes the code and opens a PR. ★ 40,451repo stars Modernization Agent Exhaustive workspace assistant that inspects every business logic file, writes per-feature markdown docs, and outlines architecture migration plans. ★ 40,451repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor