← Back to Skills Marketplace
houyalei

当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。

by houyalei · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
96
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install sql-index-optimizer-multi-db
Description
当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。
README (SKILL.md)

慢 SQL 索引优化 Skill(MySQL / Oracle / PostgreSQL)

适用场景

  • 用户提供建表 SQL 与慢 SQL,想要自动出索引优化建议。
  • 目标是生成一个文件(md/json),包含候选索引与建议 DDL。

需要的信息

  1. dialectmysql / oracle / postgresql
  2. ddl_file:建表语句文件路径
  3. slow_sql_file:慢 SQL 文件路径(可多条,分号分隔)
  4. format(可选):md/json(默认 md
  5. out(可选):输出路径

执行方式

脚本路径:

  • /.cursor/skills/sql-index-optimizer-multi-db/scripts/optimize_indexes.py

示例:

python3 "/path/to/optimize_indexes.py" \
  --dialect mysql \
  --ddl-file "/path/to/schema.sql" \
  --slow-sql-file "/path/to/slow.sql" \
  --format md \
  --out "/path/to/index_optimization.mysql.md"

输出内容

  • 统计信息(表数量、慢 SQL 数量、建议索引数)
  • 每条候选索引的原因(WHERE/JOIN/ORDER 命中列)
  • 对应数据库方言的 CREATE INDEX 语句
  • 注意事项(需结合执行计划复核)

规则说明(启发式)

  • 自动识别:
    • WHERE 过滤列
    • JOIN 连接列
    • ORDER BY 排序列
  • 复合索引优先顺序:过滤列 -> 连接列 -> 排序列
  • 跳过与现有索引前缀重复的候选

限制与提醒

  • 这是规则建议,不等同于最终执行方案。
  • 生产库执行前请结合:
    • MySQL: EXPLAIN ANALYZE
    • Oracle: AWR / 执行计划
    • PostgreSQL: EXPLAIN (ANALYZE, BUFFERS)pg_stat_statements
  • 高写入表需评估索引维护成本。
Usage Guidance
This skill appears to do what it says: it heuristically parses supplied DDL + slow SQL and emits candidate CREATE INDEX statements. Before using in production: (1) review generated DDL carefully — the tool is regex-based and can mis-parse complex DDL/queries; (2) validate suggestions with EXPLAIN/EXPLAIN ANALYZE / AWR / pg_stat_statements in a safe environment; (3) do not pass arbitrary sensitive files as the input paths — the script will read any files you provide; (4) ensure you run the script with a trusted Python interpreter (python3) and review the bundled script if you have strict security policies. If you enable autonomous invocation for agents, be aware an agent with access to files could run this script on any file paths it can access — grant file access accordingly.
Capability Analysis
Type: OpenClaw Skill Name: sql-index-optimizer-multi-db Version: 1.0.0 The skill is a legitimate utility for generating database index recommendations based on DDL and slow SQL logs. The Python script (optimize_indexes.py) uses standard libraries and regular expressions to parse SQL files and write reports locally; it contains no network activity, obfuscation, or unauthorized execution logic.
Capability Assessment
Purpose & Capability
The skill name/description match the included Python script and SKILL.md: both describe parsing DDL and slow SQL to produce candidate CREATE INDEX statements for mysql/oracle/postgresql. There are no unrelated environment variables, binaries, or external services requested.
Instruction Scope
SKILL.md instructs the agent to run the bundled Python script with user-supplied paths for DDL and slow SQL files and to output a .md/.json result. The instructions do not direct reading other system files, environment variables, or sending data to external endpoints.
Install Mechanism
No install spec is provided (instruction-only). The skill includes a local Python script that the agent runs; there are no downloads, package installs, or external installers referenced.
Credentials
The skill requires no environment variables, credentials, or config paths. The code operates on files provided by the user and does not access secrets or external services.
Persistence & Privilege
always is false and the skill is user-invocable. It does not request persistent presence or modify other skills or system-wide settings.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install sql-index-optimizer-multi-db
  3. After installation, invoke the skill by name or use /sql-index-optimizer-multi-db
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
Initial release for automated SQL index optimization on MySQL, Oracle, and PostgreSQL. - Parses table DDL and slow SQL statements to suggest candidate indexes. - Generates CREATE INDEX statements tailored to the target database. - Outputs results to markdown or JSON file, including reasons and statistics. - Supports prioritizing composite indexes and avoids redundant suggestions. - Provides guidance for final verification and notes on index impact.
Metadata
Slug sql-index-optimizer-multi-db
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is 当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。?

当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。 It is an AI Agent Skill for Claude Code / OpenClaw, with 96 downloads so far.

How do I install 当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。?

Run "/install sql-index-optimizer-multi-db" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is 当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。 free?

Yes, 当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。 is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does 当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。 support?

当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。 is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created 当用户希望“通过建表语句 + 慢 SQL 自动优化索引”时使用此 Skill,支持 MySQL、Oracle、PostgreSQL。脚本使用 Python,自动解析 DDL 与慢 SQL 中的 WHERE/JOIN/ORDER BY 列,生成候选索引及对应数据库的 CREATE INDEX 语句,并输出到文件。?

It is built and maintained by houyalei (@houyalei); the current version is v1.0.0.

💬 Comments