Agent skill · data analytics · jeremylongshore
analyzing-query-performance
Execute use when you need to work with query optimization.
Why this skill is useful
Adds automation scripts for analyzing query performance and generating optimization recommendations that are not commonly known.
What it needs
Requires mongosh, mysql, psql installed locally. About 4k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
Query Performance Analyzer Overview Analyze slow database queries using execution plans, wait statistics, and I/O metrics across PostgreSQL, MySQL, and MongoDB. This skill captures EXPLAIN output, identifies sequential scans on large tables, detects missing indexes, measures buffer cache hit ratios, and produces actionable optimization recommendations ranked by expected performance impact. Prerequisites Database credentials with permissions to run EXPLAIN ANALYZE (PostgreSQL), EXPLAIN FORMAT=JSON (MySQL), or explain() (MongoDB) pgstatstatements extension enabled for PostgreSQL (provides aggregated query statistics) Access to slow query logs or performanceschema (MySQL) Baseline query execution times for comparison psql, mysql, or mongosh CLI tools installed Instructions 1. Identify the slowest queries by examining pgstatstatements (PostgreSQL): SELECT query, calls, meanexectime, totalexectime FROM pgstatstatements ORDER BY meanexectime DESC LIMIT 20. For MySQL, enable and query the slow query log or performanceschema.eventsstatementssummarybydigest. 2. Run EXPLAIN (ANALYZE, BUFFERS, FORMAT JSON) on each slow query in PostgreSQL, or EXPLAIN ANALYZE FORMAT=JSON in MySQL. Capture the full execution plan including actual row counts, loop iterations, and buffer usage. 3. Analyze the execution plan for these red flags: Sequential scans on tables with >10,000 rows (indicates missing index) Nested loop joins with high outer row counts (consider hash join or merge join) Sort operations without index support (adding a covering index eliminates the sort) High rowsremovedbyfilter relative to rows (predicate not selective enough) Bitmap heap scans with high recheck rate (index selectivity too low) 4. Check buffer cache performance: SELECT heapblksread, heapblkshit, heapblkshit::float / (heapblkshit + heapblksread) AS cachehitratio FROM pgstatiousertables WHERE relname = 'tablename'. A ratio below 0.95 suggests the working set exceeds available sharedbuffers. 5. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/analyzing-query-performance