---
name: db-query-analyzer
description: Analyze database query performance with execution plans and index recommendations
allowed-tools:
  - Bash
  - Read
  - Write
  - Glob
graph:
  domains: [domain:software-engineering]
  specializations: [specialization:software-architecture]
  skillAreas: [skill-area:backend-data-persistence, skill-area:postgres-tuning]
  roles: [role:backend-engineer, role:architect]
  workflows: [workflow:technical-debt-reduction]
  topics: [topic:technical-debt]

---

# Database Query Analyzer Skill

## Overview

Analyzes database query performance including execution plan analysis, index recommendations, slow query identification, and optimization suggestions.

## Capabilities

- Query execution plan analysis
- Index recommendation
- Slow query identification
- Query optimization suggestions
- Table scan detection
- Join optimization analysis
- Support for PostgreSQL, MySQL, SQL Server

## Target Processes

- performance-optimization
- data-architecture-design

## Input Schema

```json
{
  "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": "Database connection string (optional, for live analysis)"
    },
    "options": {
      "type": "object",
      "properties": {
        "analyzeExplain": {
          "type": "boolean",
          "default": true
        },
        "suggestIndexes": {
          "type": "boolean",
          "default": true
        },
        "slowQueryThreshold": {
          "type": "number",
          "default": 1000,
          "description": "Slow query threshold in milliseconds"
        }
      }
    }
  }
}
```

## Output Schema

```json
{
  "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"
    }
  }
}
```

## Usage Example

```javascript
{
  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
      }
    }
  }
}
```


---
Source attribution: a5c-ai
Original project: https://github.com/a5c-ai/babysitter/blob/feb68abe397acc14f32b34984975c48fedba2b33/library/specializations/software-architecture/skills/db-query-analyzer/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

# MIT License

Copyright (c) 2025 A5C AI

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: a5c-ai
Original project: https://github.com/a5c-ai/babysitter/blob/feb68abe397acc14f32b34984975c48fedba2b33/library/specializations/software-architecture/skills/db-query-analyzer/SKILL.md
Attribution basis: Recovered original package and original project license at a pinned revision

Fields of work: Data & Analytics, Development & Engineering, Operations
Roles: Business Process Analyst, Data Analyst, Data Scientist, Database Administrator, ML / AI Engineer
Specialties: Database
Tools: MySQL, PostgreSQL
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: a89091f49ec0e1107d584a414f6ed1553ee7c460685fdcd8a806b6fbdb01a9b0
Metadata reviewed: 2026-10-27
This metadata supersedes earlier Dave AI catalog attribution. Original instruction and supporting files are preserved.
