Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

analyzing-query-performance分析查询性能

Agent Skill

analyzing-query-performance 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

685

周安装

28

GitHub Stars

2,106

下载量

222
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:analyzing-query-performance(分析查询性能)
来源仓库:https://github.com/jeremylongshore/claude-code-plugins-plus-skills
仓库路径:skills/analyzing-query-performance
安装命令:
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill analyzing-query-performance
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/jeremylongshore/claude-code-plugins-plus-skills --skill analyzing-query-performance

简介

分析数据库查询性能,识别慢查询、缺失索引和 I/O 瓶颈。

  • 适用于 PostgreSQL、MySQL 和 MongoDB 的 EXPLAIN 输出分析。
  • 通过执行计划、等待统计和缓存命中率提供优化建议。
  • 需数据库凭据及 pg_stat_statements 扩展支持。
  • 用于生产环境性能调优,不替代实时监控系统。

SKILL.md

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)
  • pg_stat_statements extension enabled for PostgreSQL (provides aggregated query statistics)
  • Access to slow query logs or performance_schema (MySQL)
  • Baseline query execution times for comparison
  • psql, mysql, or mongosh CLI tools installed

Instructions

  1. Identify the slowest queries by examining pg_stat_statements (PostgreSQL): SELECT query, calls, mean_exec_time, total_exec_time FROM pg_stat_statements ORDER BY mean_exec_time DESC LIMIT 20. For MySQL, enable and query the slow query log or performance_schema.events_statements_summary_by_digest.
  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 rows_removed_by_filter relative to rows (predicate not selective enough) - Bitmap heap scans with high recheck rate (index selectivity too low)

  1. Check buffer cache performance: SELECT heap_blks_read, heap_blks_hit, heap_blks_hit::float / (heap_blks_hit + heap_blks_read) AS cache_hit_ratio FROM pg_statio_user_tables WHERE relname = 'table_name'. A ratio below 0.95 suggests the working set exceeds available shared_buffers.
  2. Evaluate index usage with SELECT indexrelname, idx_scan, idx_tup_read, idx_tup_fetch FROM pg_stat_user_indexes WHERE schemaname = 'public' ORDER BY idx_scan ASC. Indexes with zero scans are unused and waste write performance.
  3. Check for table bloat using SELECT relname, n_live_tup, n_dead_tup, n_dead_tup::float / GREATEST(n_live_tup, 1) AS dead_ratio FROM pg_stat_user_tables WHERE n_dead_tup > 1000 ORDER BY dead_ratio DESC. A dead tuple ratio above 0.2 indicates the table needs VACUUM.
  4. For each identified issue, generate a specific recommendation: CREATE INDEX statement with the exact columns, query rewrite suggestions, or configuration parameter adjustments.
  5. Estimate the performance impact of each recommendation by comparing the EXPLAIN plan before and after applying the change on a staging database or by analyzing the expected row reduction from new indexes.
  6. Prioritize recommendations by impact-to-effort ratio: index additions (high impact, low effort) before query rewrites (medium impact, medium effort) before schema changes (high impact, high effort).
  7. Generate a performance analysis report with before/after execution plans, estimated improvements, and implementation priority ranking.

Output

  • Slow query inventory with execution frequency, mean/P95 duration, and total time consumed
  • Annotated execution plans highlighting sequential scans, sort bottlenecks, and join inefficiencies
  • Index recommendations as ready-to-execute CREATE INDEX statements with expected impact
  • Query rewrite suggestions with original and optimized SQL side by side
  • Buffer cache analysis with shared_buffers sizing recommendations
  • Performance report ranking all findings by severity and implementation priority

Error Handling

ErrorCauseSolution
EXPLAIN ANALYZE takes too long on productionQuery modifies data or runs for minutesUse EXPLAIN without ANALYZE for estimated plans; run EXPLAIN ANALYZE on staging with representative data
pg_stat_statements not availableExtension not installed or not in shared_preload_librariesRun CREATE EXTENSION pg_stat_statements; add to shared_preload_libraries in postgresql.conf and restart
Execution plan differs between staging and productionDifferent data distribution, statistics, or configurationRun ANALYZE on staging tables to update statistics; match work_mem, random_page_cost, and effective_cache_size settings
Index recommendation causes slow writesToo many indexes on a write-heavy tableLimit indexes to 5-7 per table; use partial indexes to reduce scope; consider covering indexes to replace multiple single-column indexes
Query plan uses wrong indexStale statistics or cost model miscalculationRun ANALYZE table_name to refresh statistics; adjust random_page_cost for SSD storage; use SET enable_seqscan = off to test index plans

Examples

Optimizing a dashboard aggregate query: A query computing daily revenue with GROUP BY date and JOIN across orders and line_items takes 12 seconds. EXPLAIN reveals a sequential scan on line_items (5M rows). Adding a composite index on (order_id, created_at) with INCLUDE (amount) reduces execution to 200ms by enabling an index-only scan.

Diagnosing N+1 query pattern: Application loads a list page showing 50 products, each with a separate query for category name. pg_stat_statements reveals SELECT name FROM categories WHERE id = $1 called 50 times per page load. Resolution: rewrite as a single JOIN query or implement eager loading in the ORM.

Identifying bloated table causing cache misses: Buffer cache hit ratio drops to 0.78 on the sessions table. Investigation reveals 80% dead tuples due to aggressive INSERT/DELETE cycling without autovacuum tuning. Setting autovacuum_vacuum_scale_factor = 0.01 and running VACUUM FULL restores cache hit ratio to 0.99.

Resources

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.81%
按下载量换算82

Claude

29.17%
按下载量换算65

Cursor

19.75%
按下载量换算44

Gemini CLI

9.05%
按下载量换算20

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills