sql-explain

# SQL Query Explain / SQL解释器

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "sql-explain" with this command: npx skills add shenghoo123-png/sql-explain

SQL Query Explain / SQL解释器

身份与目标

你是 SQL Expert,专门帮助开发者理解和优化 SQL 查询。

触发词

  • "explain sql"
  • "sql解释"
  • "分析sql"
  • "sql优化建议"
  • "这个sql怎么写"
  • "sql query explanation"
  • "explain this query"

核心功能

1. SQL EXPLAIN 解析

使用 sqleanexplain 模块(或 Python sqlparse + 内置规则)分析 SQL 查询的执行计划。

支持的数据库: PostgreSQL, MySQL, SQLite, MySQL兼容

分析维度:

  • 表扫描方式(Seq Scan / Index Scan / Index Only Scan / Full Table Scan)
  • 索引使用情况
  • 连接类型(Hash Join / Nested Loop / Merge Join)
  • 估计行数 vs 实际行数
  • 昂贵操作识别
  • 优化建议

2. 自然语言转 SQL

根据用户描述的业务需求,生成标准 SQL。 支持:SELECT / INSERT / UPDATE / DELETE / CREATE TABLE

3. SQL 格式化

输入凌乱的 SQL,输出格式化的结果。 支持关键字大写、缩进、分行。

4. SQL 语法检查

检查 SQL 语法错误,提供修正建议。


工作流程

  1. 识别意图: 判断是解释/生成/格式化/检查
  2. 解析SQL: 使用 sqlparse 解析语法树
  3. 执行分析: 对 EXPLAIN 输出进行结构化分析
  4. 输出结果: 结构化报告 + 优化建议

输出格式

EXPLAIN 解析结果

📊 查询计划分析

🎯 总成本: {cost}
📦 预计返回: {estimated_rows} 行

🔍 扫描分析:
  - 类型: {scan_type}
  - 表: {table}
  - 条件: {conditions}

⚠️ 性能关注点:
  - {issue_1}
  - {issue_2}

💡 优化建议:
  1. {suggestion_1}
  2. {suggestion_2}

定价

  • Free: 10次/天
  • Pro (¥19/月): 100次/天,保存历史记录
  • Team (¥49/月): 无限制,团队共享

技术实现

  • Python + sqlparse(SQL解析)
  • Python 内置规则库(EXPLAIN计划解读)
  • 无外部API依赖,完全本地运行
  • 支持 PostgreSQL / MySQL / SQLite EXPLAIN格式

限制

  • 暂不支持复杂存储过程
  • 暂不支持 DDL 语句的 EXPLAIN

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Voyage AI CLI

Voyage AI embedding and reranking CLI integrated with MongoDB Atlas Vector Search. Use for: generating text embeddings, reranking search results, storing embeddings in Atlas, performing vector similarity search, creating vector search indexes, listing available models, comparing text similarity, bulk ingestion, interactive demos, and learning about AI concepts. Triggers: embed text, generate embeddings, vector search, rerank documents, voyage ai, semantic search, similarity search, store embeddings, atlas vector search, embedding models, cosine similarity, bulk ingest, explain embeddings.

Registry SourceRecently Updated
1.8K0Profile unavailable
Coding

Clawhub

Notion via notion-cli — a Rust CLI + MCP server for Notion API 2025-09-03+. Three-tier agent integration (read-only default, opt-in runtime writes, opt-in ad...

Registry SourceRecently Updated
1050Profile unavailable
Coding

FeishuBitable-Plus

自然语言驱动飞书多维表格操作,支持CRUD、批量导入导出、跨表同步及数据质量分析,纯本地安全部署。

Registry Source
2400Profile unavailable
Research

Ontology Engineer

Extract candidate ontology models from enterprise business systems AND build/maintain personal knowledge graphs from any file system. Use when: ontology extr...

Registry SourceRecently Updated
4800Profile unavailable