sql-optimization-patterns
它能做什么
这个工具可以帮你找到并修复让数据库查询变慢的问题。它会分析数据库执行你命令的方式,并给出改进建议,比如添加索引或重写查询语句,让整体运行得更快。
适用场景
- ✓当数据库查询的响应时间太长时。
- ✓在设计或调整数据库结构、想提升性能时。
- ✓想弄清楚数据库为什么负载过高,以及如何减轻这些负载时。
技能链接
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/sql-optimization-patterns/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我用来获取用户的 SQL 查询非常慢,你能帮我优化一下吗?”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会分析你查询的“执行计划”,也就是数据库决定如何执行这条命令的过程。根据分析结果,它会建议调整,比如添加索引或重写查询,让查询更高效。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
SQL Optimization Patterns
Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.
Use this skill when
- Debugging slow-running queries
- Designing performant database schemas
- Optimizing application response times
- Reducing database load and costs
- Improving scalability for growing datasets
- Analyzing EXPLAIN query plans
- Implementing efficient indexes
- Resolving N+1 query problems
Do not use this skill when
- The task is unrelated to sql optimization patterns
- You need a different domain or tool outside this scope
Instructions
- Confirm database engine/version, query parameters, expected rows, data distribution and the permitted environment. Start read-only; obtain authorization before DDL, data changes, configuration changes or maintenance.
- Compare result sets before comparing performance. EXPLAIN ANALYZE executes the statement: use approved representative data, account for functions and triggers, and do not assume a transaction rollback undoes every side effect.
- Record the observed plan, timing conditions and correctness checks. Indexes and query rewrites are hypotheses, not universal speed improvements.
- If detailed examples are required, open
resources/implementation-playbook.md.
Resources
resources/implementation-playbook.mdfor detailed patterns and examples.
Limitations
- Use this skill only when the task clearly matches the scope described above.
- Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
- Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
Worked example
The playbook includes an executable SQLite batch-loading example with bound values and an empty-input case. The repository test exercises it alongside pagination ties and aggregation equivalence. SQLite correctness checks do not establish PostgreSQL performance or production safety.
常见问题
什么是“执行计划”?
它是数据库为找到并返回你所请求的数据而选择的路径。分析它有助于看出瓶颈在哪里。
什么是“索引”?
它就像书的目录。借助索引,数据库可以快得多地找到特定信息,而不必逐条读取全部内容。
这个工具会直接修改我的数据库吗?
不会。它只会提出建议,在做任何修改之前都会先征得你的同意,并且会从只读分析开始。
详情
作者的原始描述
Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.
热度
- GitHub 星标
- 48k
- 排名
- #5845
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
00-andruia-consultant
48k帮你的智能体启动或改进 AI 项目。它可以分析代码、推荐工具,并用西班牙语制定行动计划。
007
48k让你的智能体执行安全审计和威胁建模。它有助于保护项目免受攻击和漏洞的威胁。
10-andruia-skill-smith
48k帮你的智能体创建或改进 AI 工具。它可以定义工具的工作方式、编写文档,并验证其结构。
20-andruia-niche-intelligence
48k让你的智能体创建某个特定行业的摘要。它有助于借助可靠的信息来源,了解项目的背景、规则、使用模式和风险。