dba-rds-slow-query

Diagnose RDS PostgreSQL slow queries using pg_stat_statements and CloudWatch metrics.

Updated Apr 5, 2026
One-click install
npx skills add https://github.com/schoolofdevops/401 --skill dba-rds-slow-query-schoolofdevops
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dba-rds-slow-query
Source: https://github.com/schoolofdevops/401/tree/main/agents/track-a-database/skills/dba-rds-slow-query
Command: npx skills add https://github.com/schoolofdevops/401 --skill dba-rds-slow-query-schoolofdevops

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When a CloudWatch RDS CPU alarm fires or applications report slow database queries, on-call engineers need a structured, read-only investigation workflow to find the root cause without risking schema changes or production impact. ## Core Features & Use Cases - Slow Query Identification: Query pg_stat_statements for the top 10 slowest queries by mean execution time and flag any exceeding 1000ms. - Index Gap Analysis: Cross-reference sequential scan ratios from pg_stat_user_tables with slow queries to formulate CREATE INDEX CONCURRENTLY recommendations. - Parameter Group Review: Inspect work_mem, shared_buffers, and max_connections values and correlate them with query patterns like ORDER BY or GROUP BY. - Use Case: A CloudWatch alarm reports CPUUtilization above 80% on prod-db-01. Run this Skill to gather instance status, CPU and connection metrics, and pg_stat_statements output, then receive a diagnosis: missing index, connection saturation, parameter tuning, or developer escalation. ## Quick Start Investigate slow queries on my RDS instance prod-db-01 in us-east-1 and tell me whether the high CPU is caused by missing indexes, connection saturation, or parameter settings.

Frequently Asked Questions about dba-rds-slow-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I find slow queries in RDS PostgreSQL?

Query pg_stat_statements ordered by mean_exec_time descending to find the slowest queries. This Skill flags any query with mean execution time above 1000ms and cross-references it with table scan statistics to identify the cause.

How to check for missing indexes in PostgreSQL?

Query pg_stat_user_tables and calculate the sequential scan percentage. Tables with seq_scan_pct above 80% and more than 100 sequential scans are index candidates, which you cross-reference with slow query text to propose CREATE INDEX CONCURRENTLY statements.

What permissions are needed to investigate RDS slow queries?

You need read-only AWS permissions: rds:DescribeDBInstances, rds:DescribeDBParameters, and cloudwatch:GetMetricStatistics. On the database side, the PostgreSQL user needs the pg_read_all_stats role to read pg_stat_statements.

Why is RDS CPU high but no single query is slow?

High CPU without individual slow queries usually indicates high query volume or connection saturation. Check DatabaseConnections in CloudWatch; if it exceeds roughly 130 on a db.t3.medium, connection pooling with PgBouncer is the recommended fix.

Can this Skill fix slow queries automatically?

No, the Skill is strictly read-only and never executes DDL, parameter changes, or connection termination. It formulates recommendations such as index creation or work_mem tuning, which require DBA approval through a change window.

When should I not use this slow query investigation workflow?

Do not use it for connection pool configuration issues, replication lag, or storage capacity problems, as those require separate diagnostic workflows. It is scoped specifically to query performance, index gaps, and parameter group review.