名称:数据库查询分析器 描述:通过执行计划和索引推荐分析数据库查询性能 允许使用的工具:
- Bash
- Read
- Write
- Glob
数据库查询分析器技能
概述
分析数据库查询性能,包括执行计划分析、索引推荐、慢查询识别和优化建议。
能力
- 查询执行计划分析
- 索引推荐
- 慢查询识别
- 查询优化建议
- 表扫描检测
- 连接优化分析
- 支持 PostgreSQL、MySQL、SQL Server
目标流程
- 性能优化
- 数据架构设计
输入模式
{
"type": "object",
"required": ["queries"],
"properties": {
"queries": {
"type": "array",
"items": {
"type": "object",
"properties": {
"sql": { "type": "string" },
"name": { "type": "string" }
}
}
},
"database": {
"type": "string",
"enum": ["postgresql", "mysql", "sqlserver", "oracle"],
"default": "postgresql"
},
"connectionString": {
"type": "string",
"description": "数据库连接字符串(可选,用于实时分析)"
},
"options": {
"type": "object",
"properties": {
"analyzeExplain": {
"type": "boolean",
"default": true
},
"suggestIndexes": {
"type": "boolean",
"default": true
},
"slowQueryThreshold": {
"type": "number",
"default": 1000,
"description": "慢查询阈值(单位:毫秒)"
}
}
}
}
}
输出模式
{
"type": "object",
"properties": {
"analyses": {
"type": "array",
"items": {
"type": "object",
"properties": {
"query": { "type": "string" },
"executionPlan": { "type": "object" },
"estimatedCost": { "type": "number" },
"issues": { "type": "array" },
"suggestions": { "type": "array" }
}
}
},
"indexRecommendations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"table": { "type": "string" },
"columns": { "type": "array" },
"type": { "type": "string" },
"reason": { "type": "string" }
}
}
},
"slowQueries": {
"type": "array"
}
}
}
使用示例
{
kind: 'skill',
skill: {
name: 'db-query-analyzer',
context: {
queries: [
{ sql: 'SELECT * FROM users WHERE email = ?', name: 'get-user-by-email' }
],
database: 'postgresql',
options: {
analyzeExplain: true,
suggestIndexes: true
}
}
}
}