sql-optimization-patterns – Data & Science skill for AI agents
Diagnose slow SQL with query plans, preserve query results, and verify indexing or query changes against representative data.
Install the sql-optimization-patterns skill with one command
Pick the tool you use, copy the command and paste it in your terminal. The skill lands in that tool's skills folder and is ready in your next session.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-optimization-patterns-b5ef1.tgz | tar xz -C ~/.claude/skills
Call it in Claude Code: /sql-optimization-patterns – then describe the task you want done.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-optimization-patterns-b5ef1.tgz | tar xz -C ~/.codex/skills
Call it in Codex: $sql-optimization-patterns – then describe the task you want done.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-optimization-patterns-b5ef1.tgz | tar xz -C ~/.hermes/skills
Call it in Hermes Agent: /sql-optimization-patterns – then describe the task you want done.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/sql-optimization-patterns-b5ef1.tgz | tar xz -C ~/.deepcode/skills
Call it in DeepSeek: /sql-optimization-patterns – then describe the task you want done.
SKILL.md content
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.
Related skills
- sql-pro – Master modern SQL with cloud-native databases, OLTP/OLAP optimization, and advanced…
- sql-sentinel – Audit SQL for the cost & performance anti-patterns that burn warehouse credits. Scores…
- sqlmap-database-pentesting – Provide systematic methodologies for automated SQL injection detection and exploitation…
- startup-analyst – Expert startup business analyst specializing in market sizing, financial modeling…
- startup-business-analyst-market-opportunity – Generate comprehensive market opportunity analysis with TAM/SAM/SOM calculations
- startup-financial-modeling – Build comprehensive 3-5 year financial models with revenue projections, cost structures…
- statsmodels – Statsmodels is Python's premier library for statistical modeling, providing tools for…
- stride-analysis-patterns – Apply STRIDE methodology to systematically identify threats. Use when analyzing system…