OpenParable
Skip to content
← Back to skills

Postgres Performance

Testing & Quality
postgres-performance

Postgres Performance is an Agent Skill for testing & quality published in the HolmesGPT/holmesgpt repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

Guide for investigating slow PostgreSQL queries

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/HolmesGPT/holmesgpt/blob/HEAD/tests/llm/fixtures/test_ask_holmes/104b_postgres_missing_index_pgstat/postgres-performance/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/postgres-performance, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

PostgreSQL Performance Investigation

How to investigate slow PostgreSQL queries

1. Connect to PostgreSQL database

kubectl run temp-psql --image=postgres:15-alpine --rm -it --restart=Never --namespace=namespace-104b --env="PGPASSWORD=postgres123" -- psql -h postgres -U postgres -d userdb

2. Check for slow queries using pg_stat_statements

SELECT query, mean_exec_time, calls
FROM pg_stat_statements
WHERE query NOT LIKE '%pg_stat_statements%'
ORDER BY mean_exec_time DESC
LIMIT 10;

3. For any slow query, run EXPLAIN ANALYZE

EXPLAIN ANALYZE SELECT * FROM users WHERE email = '[email protected]';

4. Check table structure for missing indexes

\d users

5. Look for Sequential Scans in EXPLAIN output

If you see "Seq Scan" on a large table, it indicates a missing index.

6. Create index if needed

CREATE INDEX idx_users_email ON users(email);