🗄️
DataPython

SQL Optimization Expert

by val1813

SQL Optimization Expert is a Data skill for Claude Code, published by val1813 in kwcode.

688 stars92 forkson val1813/kwcodeAdded 2026/08/12Repository updated 2026/05/14
Install in seconds
Install SQL Optimization Expert
Copy SQL Optimization Expert into your Claude Code skills folder. Run the command in your terminal, or review the source on GitHub before installing.
terminal
npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/sqlopt ~/.claude/skills/sqlopt

Requires Node.js. Downloads this skill only — not the rest of the repository — into your Claude Code skills folder.

Without Node.js

git clone https://github.com/val1813/kwcode.git

Clones the whole repository, then copy the skill’s own directory into your skills folder yourself.

In this catalog

Source file
kaiwu/builtin_experts/sqlopt/SKILL.md in val1813/kwcode
Installs to
~/.claude/skills/sqlopt
Collection
One of 19 skills cataloged from this repository
Category
Data668 skills

What SQL Optimization Expert does

SQL Optimization Expert explains how to tune MySQL queries and indexes using EXPLAIN, index design, pagination, joins, and batch updates. Use it when a query is slow, a plan is inefficient, or an index is not being used.

SQL Optimization Expert is cataloged under Data on DirSkills.

Documentation

README

领域知识

  • EXPLAIN分析:关注type列(ALL全表扫描→需优化,ref/range/const为佳)、rows估算、Extra中的Using filesort/temporary
  • 索引设计:WHERE条件列建索引,联合索引遵循最左前缀原则,区分度高的列放前面
  • 覆盖索引:SELECT的列都在索引中,避免回表(Extra显示Using index)
  • 避免索引失效:不在索引列上用函数/运算、不用前导%LIKE、注意隐式类型转换
  • 子查询改JOIN:IN子查询改为INNER JOIN,EXISTS改为LEFT JOIN + IS NOT NULL判断
  • 分页优化:深分页用WHERE id > last_id LIMIT n代替OFFSET,或延迟关联
  • 批量操作:INSERT用批量VALUES(每批500-1000条),UPDATE用CASE WHEN批量
  • COUNT优化:COUNT(*)让引擎选最小索引,不要COUNT(列名)除非需排除NULL
  • 大表JOIN:确保JOIN字段有索引且类型一致,小表驱动大表
  • 锁优化:长事务拆短、避免SELECT...FOR UPDATE范围过大

经验规则(自动生成)

Frequently asked about SQL Optimization Expert

  • What else does val1813 publish alongside SQL Optimization Expert?

    SQL Optimization Expert is one of 19 skills that DirSkills catalogs from val1813/kwcode, the repository it ships in. Its siblings there include API Expert, Bug Fix Expert and DeepSeek API Expert. Each one is a separate skill with its own page in this directory, installs the same way SQL Optimization Expert does, and is maintained by val1813 in that same repository. The rest of the collection is listed on the val1813/kwcode page.

  • How does SQL Optimization Expert compare to other Data skills?

    SQL Optimization Expert ranks #537 by stars among the 668 Data skills in this catalog. The most-starred ones next to it are Benchmark Methodology, Jupyter Notebook and Solana. DirSkills ranks by the star count of the repository each skill ships in, so that order reflects how popular those repositories are rather than any review of SQL Optimization Expert against them. Open each page to compare what they document and how they install.

More from val1813/kwcode

SQL Optimization Expert is one of 19 skills cataloged on DirSkills from val1813/kwcode.

See all 19 skills