跳到正文
Skillpedia
通用编程48k · #5845

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。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/sql-optimization-patterns/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 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.md for 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.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5845
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能